简体   繁体   中英

How xpath read xml spaced elements?

This is the xml, unfortunately anything of the XML is NOT CHANGEABLE :

<allowance name ='' /> <allowance type ='' /> <allowance value='' />

And i need to obtain only "allowance value" with xpath in java. How can it be done?

This expression will return all 'allowance' elements that have the 'value' attribute:

//allowance[@value]

This will return just the value of "value":

//allowance[@value]/@value

您可以尝试:/ root // allowance [@value]

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