How to make a XPathNav select a specific node ?
Posted on 2004-04-28
Hello all !
I have the following XML file :
<?xml version="1.0" encoding="utf-8" ?>
I do NOT want to use a dataset to load it and I do NOT want to use a XmlDocument.
I want to parse it that file using the XPathNavigator.
Previously, I was using
Private m_XmlIte As XPathNodeIterator
m_XmlDoc = New XPathDocument(New IO.StringReader(XmlLabels))
m_XmlIte = m_XmlDoc.CreateNavigator.Select("descendant::ITEM")
and then iterating on the XPathNodeIterator to get my different values.
But I wanted to add a specific method to get directly the node I wanted (for instance, egtting firectly the second ITEM element without any MoveNext call)
And so I want to use something like :
m_XmlIte = m_XmlDoc.CreateNavigator.Select("descendant::ITEMS[ITEM/TXT_CODE='" & txtCode & "']")
But this syntax always give me the first ITEM element.
What is the problem ? Can I do what I want with the XPathNavigator ? Is there a mistake in my XPathExpression ?