测试xpath的工具
http://www.freeformatter.com/xpath-tester.html#ad-output
http://www.xpathtester.com/test
教程
http://www.w3school.com.cn/xpath/xpath_syntax.asp
解析xml可以安装这个包 https://github.com/yaronn/xpath.js 支持xpath。使用方法大致如下:
首先安装这个包
npm install xpath.js再安装下面这个
npm install xmldomxpath基本用法通过几个实例即可掌握
这里有一段xml
<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org"> <actors> <actor id="1">Christian Bale</actor> <actor id="2">Liam Neeson</actor> <actor id="3">Michael Caine</actor> </actors> <foo:singers> <foo:singer id="4">Tom Waits</foo:singer> <foo:singer id="5">B.B. King</foo:singer> <foo:singer id="6">Ray Charles</foo:singer> </foo:singers> </root>/
/root
/root/actors/actor
//foo:singer
//foo:singer/@id
//actor[1]/text()
//actor[last()]
//actor[position() < 3]
//actor[@id]
//actor[@id=’3′]
//actor[@id<=3]
/root/foo:singers/*
//*
//actor|//foo:singer
name(//*[1])
number(//actor[1]/@id)
string(//actor[1]/@id)
string-length(//actor[1]/text())
local-name(//foo:singer[1])
count(//foo:singer)
sum(//foo:singer/@id)
from:http://ju.outofmemory.cn/entry/73154
转载于:https://www.cnblogs.com/c-x-a/p/5481269.html
相关资源:JAVA上百实例源码以及开源项目