I am using Visual Studio 2013. I have created a ASP.Net Web API project and I have added a controller, model and other related classes. Please find below my class details
Products class
public partial class Products{
[XmlArray("Product")] // Tried this also XmlArray(ElementName = "Product")
[XmlArrayItem("productName")]
public List<string> productName { get; set; }
}
In other class, I am initializing the Products class object as mentioned below
public Products Get()
{
Products objProducts = new Products
{
productName = new List<string>
{
"P1",
"P2",
"P3"
};
};
return objProducts;
}
Whenever I execute the url (http://localhost/service/api/Products) on browser I got below XML
<Products>
<Product>
<string>P1</string>
<string>P2</string>
<string>P3</string>
</Product>
</Products>
I should like it if I could get this:
<Products>
<Product>
<productName>P1</productName>
<productName>P2</productName>
<productName>P3</productName>
</Product>
<Products>