loop through the children of the XPathNodeIterator

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I would like to loop through the children of the XPathNodeIterator (iterator).<br/> <br/> How can I do this?<br/> <br/> <br/> XPathDocument doc = new XPathDocument(destPath);<br/> // create navigator<br/> XPathNavigator navigator = doc.CreateNavigator(); <br/> // select section nodes<br/> XPathNodeIterator iterator = navigator.Select("/ClinicalDocument/component/structuredBody/component/section");<br/> try<br/> {<br/> lblStatus.Text += "The expressions returned " + iterator.Count + " nodes";<br/> lblStatus.Text += "<ol>";<br/> if (iterator.Count > 0)<br/> {<br/> while (iterator.MoveNext())<br/> {<br/> lblStatus.Text += "" + iterator.Current.LocalName + ""; <br/> }<br/> }<br/> else<br/> {<br/> lblStatus.Text = "No results";<br/> }<br/> }<br/> catch (Exception ex)<br/> {<br/> lblStatus.Text = ex.Message;<br/> }<br/> } <br/> lblStatus.Text += "</ol>";

View the full article
 
Back
Top