Here i am going to demonstrate how to parse through XML documents and iterate the node values and names in simple steps.
Step 1: Add the required name spaces
using System.Xml;
using System.Xml.XPath;
System.Xml contains classes related to Xml reading and writing and System.Xml.XPath namespace contains the classes that define a cursor model for navigating and editing XML information items as instances of the XQuery 1.0 and XPath 2.0 Data Model.
Step2:Create a XMLText Reader and load the XML Document
XML Text reader provides a fast , non cashed forward only access to XML data where as XML Document object can be used to load an XML formated file.
Step 3 :Create an XML Node List and iterate the values.
Upon running the code you can see that the values got populated to the array list from the xml.
XML Config File |
Code block |
Quick watch values |