Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XPath check for non-existing node

Tags:

Im having a bit of trouble finding the right XPath syntax to check if a particular node in my XML exists. I'm only allowed to use XPath (so no XSL or something else like that, it has to be a pure XPath expression syntax).

I have an XML and it has a node Filename but it doesn't exist in every case. When the filename isn't specified, my LiveCycle proces will use a different route to fill in the filename. But how do I check if the Filename node exists?

like image 217
Ronny176 Avatar asked Jul 23 '10 09:07

Ronny176


1 Answers

You can use the count function - passing in the path of the nodes you are checking.

If they do not exist, then the value of count will be 0:

count(//Filename) = 0 
like image 133
Oded Avatar answered Sep 16 '22 15:09

Oded