[英]JDOM2 and XPath
当我运行以下
XPathFactory xpathFactory = XPathFactory.instance();
XPathExpression<Double> query =
xpathFactory.compile("count(1)", Filters.fdouble());
List<Double> result = query.evaluate(new Element("test"));
但是评估失败:
无法评估表达式。 查看原因原因:功能:count
那是个胡说八道的例子,但是我想要一些自我包含的东西。 这有什么问题?
如果要计算test
元素的数量,请尝试此操作;
Element root = new Element("test");
Document doc = new Document(root);
XPathFactory xpathFactory = XPathFactory.instance();
XPathExpression<Double> query = xpathFactory.compile("count(//test)", Filters.fdouble());
List<Double> result = query.evaluate(doc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.