I am using C# and have a question in relation to de serializing an XML string.
Here is my code to de serialize:
public object XmlDeserializeFromString(string objectData, Type type)
{
var serializer = new XmlSerializer(type);
object result;
using (TextReader reader = new StringReader(objectData))
{
result = serializer.Deserialize(reader);
}
return result;
}
The following XML works with the above function:
<House>
<address>21 My House</address>
<id>1</id>
<owner>Optimation</owner>
</House>
However, the XML from my Web API application does not:
<House xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/MVCwithWebAPIApplication.Models">
<address>21 My House</address>
<id>1</id>
<owner>Optimation</owner>
</House>
How can I get the XmlDeserializeFromString
function to work with the XML from my Web API application?