fn:contains(string1,string2)
若是 string1 包含 string2,则返回 true,不然返回 false。
例子:contains(""XML"",""XM"") 成果:true
在查询xml的时辰,经常要知道某个元素的值或其属性值是否包含了某一值。若是采取把xml转换成字符串的做法势必造成体系机能的降落。
xpath:供给了查询xml的一种路子。大师或许对数据库的sql查询语句很是熟悉,xpath就有点类似于sql查询语句,只不过它是xml的查询说话。
如,xml的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<root>
<sub name="a1" type="sub" order="1">
abcd1
</sub>
<sub name="a3" type="sub" order="2">
abcd2
</sub>
<sub name="a2" type="sub" order="3">
abcd3
</sub>
<sub name="a4" type="sub" order="3">
abcd4
</sub>
</root>
拔取属性 order包含""3""的节点 xPath写法为:
"/root/sub[contains(@order,""3"")]"
参考网址:1:http://www.w3cschool.cn/xpath_functions.html
2:http://hi.baidu.com/%D1%EE%B4%C8%C0%F6/blog/item/f314ea15962cba6dcb80c458.html