How to Parse Nested XML Nodes in C#
<p>I am very new to C#, but it seems as though this should be pretty straight forward. I am trying to parse an XML string returned from a web feed that looks like this:</p>

<pre><code>&lt;autnresponse xmlns:autn="http://schemas.autonomy.com/aci/"&gt;
  &lt;action&gt;QUERY&lt;/action&gt;
  &lt;response&gt;SUCCESS&lt;/response&gt;
  &lt;responsedata&gt;
    &lt;autn:numhits&gt;6&lt;/autn:numhits&gt;
    &lt;autn:hit&gt;
      &lt;autn:reference&gt;http://something.what.com/index.php?title=DPM&lt;/autn:reference&gt;
      &lt;autn:id&gt;548166&lt;/autn:id&gt;
      &lt;autn:section&gt;0&lt;/autn:section&gt;
      &lt;autn:weight&gt;87.44&lt;/autn:weight&gt;
      &lt;autn:links&gt;Castlmania,POUCH&lt;/autn:links&gt;
      &lt;autn:database&gt;Postgres&lt;/autn:database&gt;
      &lt;autn:title&gt;A Pouch and Mail - Castlmania&lt;/autn:title&gt;
      &lt;autn:content&gt;
        &lt;DOCUMENT&gt;
          &lt;DRETITLE&gt;Castlmania Pouch and Mail - Castlmania&lt;/DRETITLE&gt;
          &lt;DRECONTENT&gt;A paragraph of sorts that would contain content&lt;/DRECONTENT&gt;
        &lt;/DOCUMENT&gt;
      &lt;/autn:content&gt;
  &lt;/autn:hit&gt;
  &lt;autn:hit&gt;...&lt;/autn:hit&gt;
  &lt;autn:hit&gt;...&lt;/autn:hit&gt;
  &lt;autn:hit&gt;...&lt;/autn:hit&gt;
  &lt;autn:hit&gt;...&lt;/autn:hit&gt;
&lt;/autnresponse&gt;
</code></pre>

<p>with no luck.
I am using this code to start:</p>

<pre><code>XmlDocument xmlString = new XmlDocument();
xmlString.LoadXml(xmlUrl);

XmlElement root = xmlString.DocumentElement;
XmlNode GeneralInformationNode =
root.SelectSingleNode("//autnresponse/responsedata/autn:hit");

foreach (XmlNode node in GeneralInformationNode)
{
  Console.Write("reference: "+node["autn:reference"]+" Title:"+node["DRETITLE"]+"&lt;br /&gt;);
}
</code></pre>

<p>And I would like to print the DRETITLE and autn:reference element of within each of the autn:hit elements. Is that even doable with my approach?</p>

<p>I have tried looking and several example on the good old web like <a href="http://www.codeproject.com/Articles/169598/Parse-XML-Documents-by-XMLDocument-and-XDocument" rel="nofollow">this</a> to no avail. </p>

<p>The error that comes back is: </p>

<blockquote>
  <p>System.Xml.XPath.XpathEception {NameSpace Manager or XsltContext
  needed. ...}</p>
</blockquote>

<p>Thanks in advance.</p>

<p><strong>UPDATE:</strong></p>

<p>In trying to use XmlNamespaceManager, one has to give it a url to the schema definition like so: </p>

<pre><code>XmlNamespaceManager namespmng = new XmlNamespaceManager (xmlString.NameTable);
namespmng.AddNamespace("autn","http://someURL.com/XMLschema");
</code></pre>

<p>The problem seems to be that now the error is gone, but the data is not displaying. I should mention that I am working off of a machine that does not have internet connectivity. The other thing is the schema seems to be unavailable. I am guessing that XmlNamespaceManager would work once able to connect to the internet right? </p>