XPATH的簡單例子

mouqj發表於2007-09-01
基本的XPATH語法類似於FILE協議
對於XML檔案test.xml









The basic XPath syntax is similar to filesystem addressing. If the path starts with the slash / , then it represents an absolute path to the required element.
/AAA
Select the root element AAA

<AAA> <BBB/>
<CCC/>
<BBB/>
<BBB/>
<DDD>
<BBB/>
DDD>
<CCC/>
AAA>
|
/AAA/CCC
Select all elements CCC which are children of the root element AAA

<AAA>
<BBB/>
<CCC/> <BBB/>
<BBB/>
<DDD>
<BBB/>
DDD>
<CCC/>
AAA>
|
/AAA/DDD/BBB
Select all elements BBB which are children of DDD which are children of the root element AAA

<AAA>
<BBB/>
<CCC/>
<BBB/>
<BBB/>
<DDD>
<BBB/> DDD>
<CCC/>
AAA>
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11049438/viewspace-967501/,如需轉載,請註明出處,否則將追究法律責任。

相關文章