Question

When I call XPathNavigator.Select ("self::node()/../..[@numberOfLocationsAdded!='0']") I get an exception of "has an invalid token"

Is this because XPathNavigator cannot go above the root it is at? If so, any suggestions about how best to handle this case?

We call select and get an XPathNodeIterator when a user sets a node they want to iterate over.
Then for each iteration we call XPathNodeIterator.Current which gives us an XPathNavigator for the node we are on.

And then for XPath selects against the node we are on, call XPathNavigator.Select()

Is there a way to do this efficiently? Or if we need to support ../.. do we need to always work off the root node and prepend the XPath of the nodes they want to iterate over?

thanks - dave

Was it helpful?

Solution

This is syntactically invalid in XPath 1.0:

..[condition]

Use:

self::node()/../../self::*[@numberOfLocationsAdded!='0']

or the equivalet and shorter:

../parent::*[@numberOfLocationsAdded!='0']
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top