This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Check For Empty Nodeset

Hi all,

I'm running a query in a policy and need to check if anything was found. At the moment I check:

XPath(count($resultNodeset) > 0

Is there a better way? Does a DirXML nodeset have something like JS .length that I can check?

Parents
  • 0

    In a query-response you can simply look for the existence of an <instance>-element with a src-dn attribute.

    As for nodesets in general, it really depends on what you mean by "empty". A Node with nothing in it (i.e. its value is the empty string) is still included by count(). If you count that as being empty you'd have to filter out those nodes first: count($nodeset[string-length(.) != 0]), otherwise count() should be sufficient.

Reply
  • 0

    In a query-response you can simply look for the existence of an <instance>-element with a src-dn attribute.

    As for nodesets in general, it really depends on what you mean by "empty". A Node with nothing in it (i.e. its value is the empty string) is still included by count(). If you count that as being empty you'd have to filter out those nodes first: count($nodeset[string-length(.) != 0]), otherwise count() should be sufficient.

Children
No Data