XPath 是一門在 XML 文件中尋找資訊的語言。

XPath 節(jié)點 語法

在 XPath 中,有七種類型的節(jié)點:元素、屬性、文字、命名空間、處理指令、註解以及文件(根)節(jié)點。 XML 文件是被當作節(jié)點樹來對待的。樹的根被稱為文檔節(jié)點或根節(jié)點。

XPath 節(jié)點 範例

<?xml?version="1.0"?encoding="UTF-8"?>
<bookstore>
??<book>
????<title>Harry?Potter</title>
????<author>J?K.?Rowling</author>
????<year>2005</year>
????<price>29.99</price>
??</book>
</bookstore>

上面的XML文檔中的節(jié)點範例:

<bookstore>?(文檔節(jié)點)
<author>J?K.?Rowling</author>?(元素節(jié)點)
lang="en"?(屬性節(jié)點)