我在學習XPath語法。我使用的是W3Schools的例子在這裏:在XPath中選擇過濾節點集的屬性
http://www.w3schools.com/xsl/tryit.asp?filename=try_xpath_select_pricenodes_high
..這是基於以下XML:
<?xml version="1.0" encoding="UTF-8""?>
<bookstore>
<book category="COOKING">
<title la="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
的例子選擇具有價格比35.我越大的書籍標題想玩這個例子,並選擇類別名稱,而不是標題。所以,我試過這個:
/bookstore/book[price>35]/@category
而且,正如你在該網站上自己測試它所看到的那樣,它不產生任何輸出。我錯了什麼?
謝謝你的時間。
您的示例沒有任何價格> 35的書。是否是錯字? –