簡體   English   中英

如何根據其父節點的屬性值查詢XML節點

[英]How to query XML nodes based on the value of the attribute of its parent node

我有一個看起來像這樣的XML:

<Library>
<Author Name = "JRR Tolkien">
<Book Title = "Lord Of the Rings" />
<Book Title = "The Hobbit" />
</Author>
<Author Name = "JK Rowling">
<Book Title = "Harry Potter and the Sorcerers Stone" />
<Book Title = "Harry Potter and the Prisoner of Azkaban" />
</Author>
</Library>

XPath是什么,用於選擇其父“ Author”節點的值為“ JK Rowling”的所有“ Book”節點?

這是最直觀,最嚴格的選擇,將所有具有“ Author Name屬性為'JK Rowling' Author 'JK Rowling'選為父本。 並且Author還必須擁有Library作為父母。

/Library/Author[@Name='JK Rowling']/Book

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM