简体   繁体   中英

Xpath - select multiple values (key value pairs)

Having this XML:

       <slot nodeId='123'>
       <properties>
        <property key="key1" value="value1"/>
        <property key="key2" value="value2"/>
        <property key="key3" value="value3"/>
        ...
        ...
        <property key="keyN" value="valueN"/>
        <property key="keyN+1" value="valueN+1"/>
       </properties></slot>

How can I get multiple values from xml, in this format:

For properties:

key='key1' and key='key10' (multiple conditions)

I want output:

value1 value10

Thx a lot!

You can try using XPath or operator to combine multiple conditions :

//properties/property[@key='key1' or @key='key10']/@value

Above XPath return value attribute from <property> nodes having key attribute value equals "key1" or "key10" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM