Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using the XmlReader class. This class is fast and does not use a lot of memory but reading the xml can be difficult.</p> <pre><code>using (StringReader strReader = new StringReader(yourXMLString)) { using (XmlReader reader = XmlReader.Create(strReader)) { while (reader.Read()) { if(reader.Name == "Table" &amp;&amp; reader.NodeType == reader.NodeType == XmlNodeType.Element) { using(XmlReader tableReader = reader.ReadSubtree()) { ReadTableNode(tableReader); } } } } } private void ReadTableNode(XmlReader reader) { while (reader.Read()) { if(reader.Name == "ID" &amp;&amp; reader.NodeType == reader.NodeType == XmlNodeType.Element) //do something else if(reader.Name == "CAT" &amp;&amp; reader.NodeType == reader.NodeType == XmlNodeType.Element) //do something //and continue.... } } </code></pre> <p>To get an attribute of the current node you use:</p> <pre><code>string value = reader.GetAttribute(name_of_attribute); </code></pre> <p>To get the inner text of an element:</p> <pre><code>string innerText = reader.ReadString(); </code></pre> <p>Using the XmlDocument class. This class is slow but manipulating and reading the xml is very easy because the entire xml is loaded.</p> <pre><code>XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(yourXMLString); //do something </code></pre> <p>Using the XDocument class. The advantage of using XDocument is elements can be accessed directly and simultaneously. This class also use the power of LINQ to query the xml document.</p> <pre><code>using(StringReader tr = new StringReader(yourXMLString)) { XDocument doc = XDocument.Load(tr); //do something } </code></pre>
 

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