title: Recurse through XML document
body: <p>I am looking for a good approach to recurse through an XML document without specifying XPATH or XQUERY expressions.  Just starting at the root node.  I need to hold on to the element and the text of the node.</p>
  
  <p>Something similar to: </p>
  
  <pre><code>    private void RecurseXml(XmlNode root)
      {
          if (root is XmlElement)
          {
              Console.WriteLine(root.Name);
              if (root.HasChildNodes)
                  RecurseXmlDocument(root.FirstChild);
              if (root.NextSibling != null)
                  RecurseXmlDocument(root.NextSibling);
          }
          else if (root is XmlText)
          {
              string text = ((XmlText)root).Value;
              Console.WriteLine(text);
          }
  </code></pre>
  
  <p>Where the recursion process determines if their are children or not versus using xpath.  The issue with the code I posted is tying the text for the element together.  So I can match on the element name in another process I have and set it equal to the value of the text. So I can use conventions to do the mapping.  </p>