Reputation: 4961
I am looking for an XPath expression that selects the him
s that have parent, gramps
's with name
's that have the same root name with the hims
having a Jr
suffix and there is a store
name
that looks like it is named after a gramps
. In the example below that would only be Bill
.
<root>
<gramps name="Bill">
<him name="Bill Jr">
<kid name="Bill III"></kid>
</him>
</gramps>
<gramps name="Tom">
<him name="Al">
<kid name="Al Jr"></kid>
</him>
</gramps>
<gramps name="Bob">
<him name="Bob Jr">
<kid name="Sam"></kid>
</him>
</gramps>
<store name="Bill's" />
<store name="Tom's" />
<store name="Pete's" />
</root>
Upvotes: 0
Views: 549
Reputation: 52858
I think this will select what you need...
/*/gramps[../store/@name=concat(@name,"'s")]/him[@name=concat(../@name,' Jr')]
This will select Bill Jr
because you said you wanted to select the him
.
If you want to select the gramps
(Bill
), just put him
in a predicate...
/*/gramps[../store/@name=concat(@name,"'s")][him[@name=concat(../@name,' Jr')]]
Upvotes: 2