我搜索过,找不到这个特定的问题。我安装了eclipse和selenium,并想要一种使用XML的方法。我找到了几个解决方案,但似乎主要是使用我不具备的源文件?我尝试下载jaxb-xjc-2.1.13.jar,这是我在网络搜索中找到的,但也许我不知道如何将它指向我的代码。对于此代码:
package automationFramework;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.xpath.*;
然后我尝试解析xml:
public static String getElementById(String id) {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbFactory.newDocumentBuilder();
Document doc = builder.parse(new File("somelocation"));
XPathFactory xpFactory = XPathFactory.newInstance();
XPath xpath = xpFactory.newXPath();
String pwdout = xpath.evaluate("/user[@id='" + id.toUpperCase() + "']/cZAR", doc);
return pwdout;
} catch (Exception e) {
return null;
}
}
等。当它试图评估" xpath.evaluate ...."行,它会抛出一个"源附件不包含文件XPathImpl.class的源#34;