子元素的 XPath 是否对父元素的其他子元素有条件?

Ami*_*dat 5 xml xpath

我想找出 XML 代码的 XPath 查询,其中city嵌套了要检查条件(是否等于“New York”)的元素 ie,并且bprice未嵌套所需的元素 ie。

这是 XML 代码:

<book>
<btitle>The Inferno</btitle>
<bprice currency = "dollars">19.99</bprice>
<bdate>2013-05-14</bdate>
<authorinfo>
    <lastname>Brown</lastname>
    <midname>G.</midname>
    <firstname>Dan</firstname>
</authorinfo>
<publisherinfo>
    <publishername>Doubleday</publishername>
    <street>1745 Broadway</street>
    <city>New York</city>
    <zip>11119</zip>
    <country>USA</country>
</publisherinfo>
</book>
Run Code Online (Sandbox Code Playgroud)

kjh*_*hes 7

这个 XPath,

/book[publisherinfo/city = 'New York']/bprice
Run Code Online (Sandbox Code Playgroud)

将根据要求选择其元素的字符串值为 的元素bprice中的那些元素。bookpublisherinfo/city"New York"