How do I create a .net object that will serialise to the following using web api
<xml>
<merchant>
<product></product>
<uri></uri>
<product></product>
<uri></uri>
<product></product>
<uri></uri>
</merchant>
How do I create a .net object that will serialise to the following using web api
<xml>
<merchant>
<product></product>
<uri></uri>
<product></product>
<uri></uri>
<product></product>
<uri></uri>
</merchant>
Use this site to generate your C# object: http://xmltocsharp.azurewebsites.net/
Use the XmlSerializer to serialize or deserialize into an Object.
XmlSerializer serializer = new XmlSerializer(typeof(YourType));
// From XML
using(StreamReader reader = new StreamReader(""))
{
var yourTypeCollection = (Person)serializer.Deserialize(reader);
}
// To XML
using(StringWriter writer = new StringWriter())
{
xmlSerializer.Serialize(writer, toSerialize);
return writer.ToString();
}