有如下的xml文件nodes.xml :
<library>
<book sum="22">helloworld
</book>
</library>
提取 "helloworld" 这个字符串 :
String filePath = "nodes.xml";
InputSource inputSource = new InputSource(filePath);
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = "/library/book[@sum='22']";
String nodes = xpath.evaluate (expression, inputSource);
参考 : xpath语法, xpath validation , easy and efficient xml
--
It's Hard to Define, But I Know it When I See it…
No comments:
Post a Comment