For example:
//person[@id='abc123']/@haircolor|/@weight"
PS. there are lots of "person" records
//div[@class='content'][2] means: Select all elements called div from anywhere in the document, but only the ones that have a class attribute whose value is equal to "content". Of those selected nodes, only keep those which are the second div[@class = 'content'] element of their parent.
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.
The | character denotes the XPath union operator. You can use the union operator in any case when you want the union of the nodes selected by several XPath expressions to be returned.
Try this:
//person[@id='abc123']/@*[name()='weight' or name()='haircolor']
If you're using an XPath 2.0 processor, you may also use a prettier option:
//person[@id='abc123']/(@haircolor|@weight)`
Are you wanting to search for person nodes based on the value of multiple attributes. If that's the question then you can just use ands e.g.
//person[@id='abc123' and @haircolor='blue' and @weight='...']
If you want to search on a single attribute, but return the values of the other attributes, I would do something like this:
<xsl:template match="person[@id='abc123']"> <xsl:value-of select="@haircolor"/> <xsl:value-of select="@weight"/> </xsl:template>
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