try {
XPath xpath = XPathFactory.newInstance().newXPath();
InputSource inputSource = new InputSource(fileName);
NodeList children = (NodeList) xpath.evaluate(rootPath + "/*",
inputSource, XPathConstants.NODESET);
for (int i = 0; i < children.getLength(); i++) {
try {
Node child = children.item( i );
String str = (String) xpath.evaluate("text()", child, XPathConstants.STRING);
props.put( child.getNodeName(), str.trim());
} catch (XPathExpressionException e) {
e.printStackTrace();
}
我看了帮助文档上写xpath.evaluate的第一个参数是表达式, 请问
rootPath + "/*",]("text()", 是什么意思,怎么理解能
ps:我看了xml中没有/* 和test 这两个字段阿
XPath xpath = XPathFactory.newInstance().newXPath();
InputSource inputSource = new InputSource(fileName);
NodeList children = (NodeList) xpath.evaluate(rootPath + "/*",
inputSource, XPathConstants.NODESET);
for (int i = 0; i < children.getLength(); i++) {
try {
Node child = children.item( i );
String str = (String) xpath.evaluate("text()", child, XPathConstants.STRING);
props.put( child.getNodeName(), str.trim());
} catch (XPathExpressionException e) {
e.printStackTrace();
}
我看了帮助文档上写xpath.evaluate的第一个参数是表达式, 请问
rootPath + "/*",]("text()", 是什么意思,怎么理解能
ps:我看了xml中没有/* 和test 这两个字段阿
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货