我正在尝试使用 JDOM(XPATH) 读取 KML。错误不会被异常捕获,只有将鼠标悬停在代码行XPath.newInstance("//Kml/Document/Placemark/LookAt"); 我看到的错误是:
XPath.newInstance("//Kml/Document/Placemark/LookAt"); = >Exception occurred in target VM: WEB9031: WebappClassLoader unable to load resource [java.lang.ExceptionInInitializerError], because it has not yet been started, or was already stopped<
我的代码:
public void lerKML() throws Exception {
String path = req.getRealPath("/Usuarios/" + pe.getEmail() + "/"+ pe.getTitulo() + "/" + pe.getNomeArquivoKMLZ());
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new File(path));
XPath xPath = XPath.newInstance("//Kml/Document/Placemark/LookAt");
Element node = (Element) xPath.selectSingleNode(document.getRootElement());
...
}
示例 KML 文件:
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<Placemark>
<name>teste</name>
<LookAt>
<longitude>-47.82056628282606</longitude>
<latitude>-15.78921645504241</latitude>
<altitude>0</altitude>
<heading>0</heading>
<tilt>0</tilt>
<range>668.1932383230591</range>
</LookAt>
</Placemark>
</Document>
</Kml>