User475983607 posted
Please see your previous posts with the same subject. These are just a few...
https://forums.asp.net/p/2152149/6250157.aspx?Re+Web+Api+using+Xml+as+input
https://forums.asp.net/t/2150988.aspx
https://forums.asp.net/t/2148554.aspx
https://forums.asp.net/t/2148398.aspx
To answer this question, you generally need to manually convert the string into a type if you don't use standard XML serialization.
namespace ConsoleCs
{
class Program
{
static void Main(string[] args)
{
string xmlDocumentText = "<book><name>Sam</name><price>Rs 123</price></book>";
XmlSerializer serializer = new XmlSerializer(typeof(book));
using (StringReader reader = new StringReader(xmlDocumentText))
{
book b = (book)(serializer.Deserialize(reader));
Console.WriteLine(b.name);
Console.WriteLine(b.price);
}
}
}
[System.SerializableAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class book
{
private string nameField;
private string priceField;
/// <remarks/>
public string name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
public string price
{
get
{
return this.priceField;
}
set
{
this.priceField = value;
}
}
}
}
Please review all you r previous threads as there is a lot of really good advice.