我有一个由解析器解析的Node theFinalNode
来自一个,我有另一个来自完全相同页面的文档,它以不同的方式解析,我想使用 找到另一个文档中的节点,所以我尝试制作这个代码:Document
sax2dom
Xpath
private Node node;
Node theFinalNode;
............
Document document = builder.parse(someURL);
XPath xpath = XPathFactory.newInstance().newXPath();
node = xpath.evaluate(document,theFinalNode, XPathConstants.NODE);
但似乎没有适合我上面提到的方式的构造函数。有什么解决办法吗?
错误
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: javax.xml.xpath.XPath.evaluate
编辑:
i changed last line into:` node = (Node) xpath.evaluate("//" + theFinalNode.getNodeName(),document, XPathConstants.NODE);
现在错误是:
Caused by: javax.xml.transform.TransformerException: A location step was expected following the '/' or '//' token.