Marklogic - 使用获取属性值的 Xpath

Marklogic - Xpath using get attribute value

我在下面显示了示例 Xml 数据,如果标题 lang ="it" 那么我想获取类别属性值?

<book category="CLASSICS">
  <title lang="it">Purgatorio</title>
  <author>Dante Alighieri</author>
  <year>1308</year>
  <price>30.00</price>
</book>

"If title lang ="it" then i want to get category attribute value ?"

XPath 应该很简单:

//book[title/@lang='it']/@category

您还可以使用以下 XPATH 表达式。 doc("XML-URI")/book[title/@lang/string() eq "it"]/@category