Hi,
In other words, David, first of all, you must decide if you want to *select*
the node or do you just want to *check* if that particular node has this
value. The implementation would differ in both cases.
Assuming you want to select only 1 node, use an
XmlDocument.SelectSingleNode("XpathExpression"). You can also use an XmlNode
in place of a XmlDocument. (To correct your code, the XPathNavigator class
does not have any method called "SelectSingleNode")
If you want to select multiple nodes and must use a XPathNavigator, then use
nav.Select("XpathExpression").
If you want to check for a value, use
myReturnValue = CType(nav.Evaluate("XpathExpression"), Type)
As far as the XPath expression to select a particular node is concerned,
that depends on your Xml. However, I have read that the more exactly you
define your expression, the better the performance.
For instance,
/ROOTNODE/CHILDNODE/GRANDCHILDNODE[.='software']
If you share your Xml format, it might be easier to define the exact Xpath
to use.
Hope this helps,
Regards,
Cerebrus.
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
David Thielen wrote:
If I want to test if the node == "software", what is the syntax to do
that?
self::node()[.='software']
would work with SelectSingleNode or Select as it finds a node set.
But of course
. = 'software'
is an allowed expression returning a boolean value, so with the XPath
API you would need the Evaluate method and not SelectSingleNode/Select.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/