Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

xmldocument to c# object

void Main()
{
   String aciResponseData = "<?xml version="1.0" encoding="UTF-8"?><tag><bar>test</bar></tag>";
   using(TextReader sr = new StringReader(aciResponseData))
   {
        var serializer = new System.Xml.Serialization.XmlSerializer(typeof(MyClass));
        MyClass response =  (MyClass)serializer.Deserialize(sr);
        Console.WriteLine(response.bar);
   }
}

[System.Xml.Serialization.XmlRoot("tag")]
public class MyClass
{
   public String bar;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #xmldocument #object
ADD COMMENT
Topic
Name
7+5 =