


XmlTextReader provides direct parsing and tokenizing of XML and implements the XML specification as well as the namespaces in the XML specification from the W3C.

Result.AppendLine(" " + level2Element.Attribute("name").Value) StringBuilder result = new StringBuilder() įoreach (XElement level1Element in (XElement level2Element in level1Element.Elements("product"))
Microsoft xml reader download how to#
The following source code shows how to read an XML file using LINQ.Ĭopy and paste the above XML code to a trext editor and save it as Product.XML Xmlnode = xmldoc.GetElementsByTagName("Product") XmlDataDocument xmldoc = new XmlDataDocument() įileStream fs = new FileStream("product.xml", FileMode.Open, FileAccess.Read) Private void button1_Click(object sender, EventArgs e) In this program it search the Node and its child Nodes and extract the data in child nodes.Ĭlick here to download the input file : product.xml Here we are using XmlDataDocument Class to read the XML file. This program read the content in Node wise. We can read an XML file in several ways depends on our requirement. The following C# program read that file and extract the contents inside the XML tag. In the previous program we create an XML file and named it as products.xml. Reading an XML file means that we are reading the information embedded in XML tags in an XML file. XML is a self describing language and it gives the data as well as the rules to extract what data it contains.
