This article and the attached source code shows how to parse XML documents using .NET XML class library classes.
The application reads the XML file and then associates the xml tags to variables which are then displayed in a message box.
The namespace System.Xml would be the only additional namespace that we would be using.
Start of by initializing a new instance of the XmlDocument class.
- XmlDocument xDoc = new XmlDocument();
Next use the load method to load the XML document from the specified stream.
- xDoc.Load("sampleXML.xml");
Use the method GetElementsByTagName() to obtain the addresses of a collection of elements that match the specified name.
- XmlNodeList name = xDoc.GetElementsByTagName("myName");
- XmlNodeList age = xDoc.GetElementsByTagName("myAge");
Display the results in a message box.
- MessageBox.Show("Name: " + name[0].InnerText);

Ramesh PalaniappanPosted Aug 29, 2016, 7:22 AM EDT
Nice
Danis LuiPosted Feb 9, 2010, 5:51 PM EST
What is the difference between XMLDocument and XMLTextReader? Thanks. Danis
rahim ismaeeliPosted Jan 18, 2010, 7:09 PM EST
tank`s
Rakesh ThakrePosted Sep 25, 2009, 9:37 PM EDT
[email protected]
vadivel pmPosted Sep 16, 2009, 9:01 PM EDT
Very good fine . It is very useful for me
Joseph ArmbrusterPosted Mar 2, 2008, 2:09 PM EST
If a schema is involved, I prefer binding my code slightly tighter to the schema in question. This can be accomplished using the XmlSerializer rather easily. Check out how I did it here: http://www.codeproject.com/KB/cs/nicexmlparsing.aspx
John PlattenPosted Sep 2, 2007, 10:30 AM EDT
Just what I needed when I needed it. Could have spent ages looking through the help for the right place to start on simple parsing. One comment for anyone else who like me has their XML in a string rather than a file at parse time. Just use LoadXML instead of Load. All else is fine in this great, straightforward, simple example.