I have the following XML file
-
...
...
You have an error in the XPath expression. If the expression starts with an /
it is relative to the document itself. You want it relative to the current node. This means you have two possible solutions
ImageSet[@Category="primary"]
This expands to child::ImageSet
. It fetches the ImageSet
element nodes that are direct children of the context node.
.//ImageSet[@Category="primary"]
Expands and normalizes to descendant::ImageSet
. It fetches any ImageSet
inside the current context, even if it is not a direct child. The .
represents the current node and //
changes the axis to descendants.