Posted on 2011-09-15 14:49
landor 閱讀(337)
評論(0) 編輯 收藏 所屬分類:
XML
1 xpath工具
firefox的xpath checker,使用方式:把xml用firefox打開,右鍵。
2 一些函數(shù):
* boolean函數(shù),把內(nèi)容轉(zhuǎn)換為boolean類型;比如:
<rules>
<rule>
<a>1</a>
<b>2</b>
<c>3</c>
</rule>
<rule>
<c>4</c>
</rule>
</rules>
XPath是:rules/rule[boolean(b)]/c,得到Node是<c>3</c>,意思是獲取存在b子節(jié)點(diǎn)的rule中的c子節(jié)點(diǎn)
b節(jié)點(diǎn)存在,則boolean(b)返回true,否則返回false
* not函數(shù)
把boolean的結(jié)果反過來,例如:
XPath是:rules/rule[not(boolean(b))]/c,得到Node是
<c>4</c>,意思是獲取不存在b子節(jié)點(diǎn)的rule中的c子節(jié)點(diǎn)