我在下面显示了示例Xml数据,如果title lang ="it"那么我想得到类别属性值?
<book category="CLASSICS">
<title lang="it">Purgatorio</title>
<author>Dante Alighieri</author>
<year>1308</year>
<price>30.00</price>
</book>
Run Code Online (Sandbox Code Playgroud)
"如果
title
lang ="it"
那时我想获得category
属性值?"
XPath应该是直截了当的:
//book[title/@lang='it']/@category
Run Code Online (Sandbox Code Playgroud)