I’ve got an xml file that looks like this:
<Records>
<Record>
<table>
<Row>
<col1>value1</col1>
</Row>
</table>
</Record>
<Record>
<table>
<Row>
<col1>value2</col1>
</Row>
</table>
</Record><Record>
<table>
<Row>
<col1>value3</col1>
</Row>
</table>
</Record>
</Records>
What I need is to select all the ROW nodes, across all records, so I’m using something like this:
rowiterator = Me.XMLDocument.CreateNavigator.Evaluate("//table/Row")
which is working, but it returns a NodeIterator that only contains the first Row node in the first record!?!
As far as I can tell, that’s the proper syntax for an xpath expression of “return all Row nodes with a parent table name anywhere in the document”.
I’ve got to be missing something simple, but I’m just not seeing it.
Any ideas?
You should use the
XPathNavigator.Selectmethod and loop through the iterator. Use theXPathNodeIterator.Currentproperty to access the currentXPathNavigatorobject in the loop.