Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Check these link that help you read the XML file in C# and better guide you which way is good to read it fast:<br> <a href="http://support.microsoft.com/kb/307548" rel="nofollow noreferrer">How to read XML from a file by using Visual C#</a><br> <a href="http://www.codeproject.com/KB/cpp/XMLReadWrite.aspx" rel="nofollow noreferrer">Using XML in C# in the simplest way</a><br> <a href="http://csharptutorial.blogspot.com/2006/10/reading-xml-fast.html" rel="nofollow noreferrer">Reading xml fast</a> </p> <p>First open your file with XmlTextReader class.</p> <pre><code>XmlTextReader reader = new XmlTextReader ("books.xml"); </code></pre> <p>After you create the XmlTextReader object, use the <code>Read</code> method to read the XML data. The Read method continues to move through the XML file sequentially until it reaches the end of the file, at which point the Read method returns a value of "False."</p> <p>To process the XML data, each record has a node type that can be determined from the <code>NodeType</code> property.</p> <pre><code>while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // The node is an element. Console.Write("&lt;" + reader.Name); Console.WriteLine("&gt;"); break; case XmlNodeType.Text: //Display the text in each element. Console.WriteLine (reader.Value); break; case XmlNodeType. EndElement: //Display the end of the element. Console.Write("&lt;/" + reader.Name); Console.WriteLine("&gt;"); break; } } </code></pre> <p>On the place of <code>Console.WriteLine</code> fill your house object with <code>reader.name</code> or properties that you have created in the xml file..</p> <p><strong>Check these for reading <a href="http://msdn.microsoft.com/en-us/library/bb387098.aspx" rel="nofollow noreferrer">XML file from Linq</a>.</strong><br> <a href="https://stackoverflow.com/questions/670563/linq-to-read-xml">LINQ to read XML</a><br> <a href="http://www.mssqltips.com/sqlservertip/1524/reading-xml-documents-using-linq-to-xml/" rel="nofollow noreferrer">Reading XML documents using LINQ to XML</a></p> <p>Check this MSDN tutorial <a href="http://msdn.microsoft.com/en-us/library/bb308960.aspx" rel="nofollow noreferrer">.NET Language-Integrated Query for XML Data</a></p> <blockquote> <p>Create Properties in your class rather than creating public elements and constructor for better implementation.</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload