<grand id="grand"> <parent> <child age="18" id="#not-grand"/> <child age="20" id="#grand"/> <!-- This is what I want to locate --> </parent> </grand>
Can anybody tell me how to express for locating the second child?
This doesn't work...
"/grand/parent/child[@id=concat('#',/grand/@id)]/@age"
Thank you.
I'm sorry. The expression is OK. I found I got some problems in other area not the expression itself.
XPath assertion uses XPath expression to select the target node and its values. It compares the result of an XPath expression to an expected value. XPath is an XML query language for selecting nodes from an XML. Step 1 − After clicking Add Assertion, select Assertion Category – Property Content.
Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
This XPath is specific to the code snippet you've provided. To select <child>
with id as #grand
you can write //child[@id='#grand']
.
To get age //child[@id='#grand']/@age
Hope this helps
I think this is what you want:
/grand/parent/child[@id="#grand"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With