XPath - search by reference
Posted: Tue Oct 27, 2015 3:37 pm
Hello!
I have a general question regarding XPath.
How can I search for the value of Object.name in data:One only by knowing the value of Object.name in data:Three, using XPath?
<data:Three abc:ID="3">
<data:Object.name>CCC</data:Object.name>
<data:Object.Container abc:resource="#2"/>
</data:Three>
<data:Two abc:ID="2">
<data:Object.name>BBB</data:Object.name>
<data:Two.Parent abc:resource="#1"/>
</data:Two>
<data:One abc:ID="1">
<data:Object.name>This is the value</data:Object.name>
</data:One>
I have searched manually using:
/abc:ABC/data:Three[data:Object.name/contains(.,'CCC')]
/abc:ABC/data:Two[@abc:ID='2']
/abc:ABC/data:One[@abc:ID='1']
/abc:ABC/data:One[@abc:ID='1']/data:Object.name
However, I would like one XPath query to search for "CCC" (first query) and then follow the abc:resource from "Three" to "One".
Alternatively find all "CCC" that are referenced by a specific data:One element.
Is this possible?
I have a general question regarding XPath.
How can I search for the value of Object.name in data:One only by knowing the value of Object.name in data:Three, using XPath?
<data:Three abc:ID="3">
<data:Object.name>CCC</data:Object.name>
<data:Object.Container abc:resource="#2"/>
</data:Three>
<data:Two abc:ID="2">
<data:Object.name>BBB</data:Object.name>
<data:Two.Parent abc:resource="#1"/>
</data:Two>
<data:One abc:ID="1">
<data:Object.name>This is the value</data:Object.name>
</data:One>
I have searched manually using:
/abc:ABC/data:Three[data:Object.name/contains(.,'CCC')]
/abc:ABC/data:Two[@abc:ID='2']
/abc:ABC/data:One[@abc:ID='1']
/abc:ABC/data:One[@abc:ID='1']/data:Object.name
However, I would like one XPath query to search for "CCC" (first query) and then follow the abc:resource from "Three" to "One".
Alternatively find all "CCC" that are referenced by a specific data:One element.
Is this possible?