XPath 对于子元素,对父元素的其他子元素有条件?



我想找出XML代码的XPath查询,其中元素即city要检查条件(是否等于例如。'New York')是嵌套的,而所需的元素即bprice没有嵌套。

下面是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>

这个XPath,

/book[publisherinfo/city = 'New York']/bprice

将根据请求选择publisherinfo/city元素的字符串值为"New York"book元素中的bprice元素。

最新更新