2016-11-01 8 views
1

条件(つまり 'New York'に等しいかどうか)をチェックする要素、すなわちcityがネストされ、必要な要素、すなわちbpriceがネストされていないXMLコードのXPathクエリを探したい。親の他の子に条件付きの子要素のXPath?

ここでは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> 

答えて

2

このXPathは、

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

publisherinfo/city要素要求されるように、"New York"の文字列値を持つbook要素内のものbpriceの要素を選択します。

関連する問題