Wednesday, 22 January 2014

Deserialization of an XML to an object in C#

Deserialization of an XML to C# class

<Book Title="My Book">
   <Publisher Reference="XYZ123">Some Publisher</Publisher>


public class Book
   public string Title;

   public Publisher Publisher;

public class Publisher
  public string Value;

  public string Reference;
Book res = new Book(); 
XmlTextReader reader = new XmlTextReader("file path"); 
res = (Book)serializer.Deserialize(reader);


No comments:

Post a Comment