Simple XML Reading,Writing and Serialization

Altough JSON became more common, XML is still an important markup language. As a snippet, I created an example project which will be creating a Books.xml file and reading it from the file.

First of all, let’s create a class called Book with parameters of book name, writer and list of readers.

 public class Book 
 private string bookName;
 public string BookName 
 get { return bookName; }
 set { bookName = value; }

 private string bookWriter;
 public string BookWriter
 get { return bookWriter; }
 set { bookWriter = value; }

 private List<string> bookReaders = new List<string>();
 public List<string> BookReaders 
 get { return bookReaders; }
 set { bookReaders = value; }

Continue reading

#class-to-xml-c, #xml, #xml-serialization