Simple XML to Object serialization
Model
class Student
{
[XmlElement("Name")]
public string Name;
}
Controller
[HttpPost]
public string ProcessXML(Student s)
{
public string ProcessXML(Student s)
{
//code
}
Global asax.cs
var xml = GlobalConfiguration.Configuration.Formatters.XmlFormatter;
xml.SetSerializer<Student>(new XmlSerializer(typeof(Student)));
xml.SetSerializer<Student>(new XmlSerializer(typeof(Student)));
Now you can post XML data as below
<Student>
<Name>balaji</Name>
</Student>
No comments:
Post a Comment