Most of the people who I’ve seen dealing with XML have some different approaches in dealing with the content.
If you want to read XML content, you normally have many way to go. Some people use XPath to retrieve the value with an XmlDocument object to retrieve what they want. Others will browse by nodes and get to what they want.
Do you see the main problem here? The problem is not that you won’t be able to read your information. The problem is the format as well as a lot of “navigation” code to get the information. The easy way to get away with conversions and navigation code is to use the XmlSerializer.
1 | [XmlRoot(ElementName = "Library")] |
This will easily create an XML with one root node with 2 attributes with ID and Name. The XML will also serialize any children with the proper attributes on them. This is an easy way to serialize as well as deserialize XML without having to mess-up with XPath, XmlDocument, node navigation, etc.