XPath: select parent node when child propertyvalue starts with value



I need to select all parent nodes of type FOO where BAR nodes are childs and the BAR node has a attribute A that starts with X.


e.g. In the example below, i would like to select FOO (id = A) because i have a BAR with attribute A starting with an X.



<rumba>
<latin>
<FOO id="A">
<BAR id="1" A="XYZ" />
<BAR id="2" A="ABC" />
</FOO>
</latin>
<salsa>
<FOO id="B">
<BAR id="3" A="UVW" />
</FOO>
</salsa>
</rumba>


I am pretty sure this can be done in XPATH, but I can't get my head wrapped around this one.


No comments:

Post a Comment