Reputation: 4879
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?
Upvotes: 1
Views: 339
Reputation: 96477
You should use the XPathNavigator.Select
method and loop through the iterator. Use the XPathNodeIterator.Current
property to access the current XPathNavigator
object in the loop.
Dim iter = xmldoc.CreateNavigator().Select("//table/Row")
While (iter.MoveNext())
Console.WriteLine(iter.Current.Value)
End While
Upvotes: 2