And I run an expression to get the value of a Node which doesn't even exist:
I get an empty string back. Now from that I can't deduce whether there's a tag there but it's got no content in it, or if it's just not there at all. Is there any way of checking if the node exists using an XPath expression or do I have to actually dive into the DOM to do this?
EDIT | Apologies, I've been sitting watching posts in this forum for the past few days and completely forgot to select a more appropriate forum for this question. [ August 06, 2007: Message edited by: Chris Corbyn ]
XPath is certainly one of the "Related Technologies" in the name of this forum, so this is the best place for your question.
If you are getting an empty string, then you must be issuing your XPath query in such a way that you get a string result. If you change it so that you request a nodeset result, you should get a nodeset with zero nodes in it when there are no nodes matching the expression.
Joined: Jan 14, 2007
Perfect, and so obvious. Doh! I tried BOOLEAN but it always returned true when the node didn't exist. NodeSet should work a treat logically.