Używam XmlPullParser
do otwarcia pliku i XPath
, aby uzyskać root. (Później będę modyfikować swój kod aby otrzymać węzeł idx
)Nieznany błąd w xpath (przy użyciu xmlpullparser)
Jestem jednak otrzymuję następujący błąd:
javax.xml.transform.TransformerException: Unknown error in XPath.
Szukałem w internecie ale nie znalazłem niczego, co mogłoby rozwiązać ten problem kwestia.
try{
XmlPullParser xpp = getResources().getXml(R.xml.x1);
XPath xpath = XPathFactory.newInstance().newXPath();
String askFor2 = "/root";
NodeList creaturesNodes = (NodeList) xpath.evaluate(askFor2, xpp, XPathConstants.NODESET);
Log.d("", "");
} catch (Exception ex) {
String err = (ex.getMessage()==null)?"run thread failed":ex.getMessage();
Log.e("bm run catch", err);
}
Mój plik XML jest
<?xml version="1.0"?>
<root>
<child index="1">
<idx index="1" />
<idx index="2" />
<idx index="3" />
<idx index="4" />
<idx index="5" />
<idx index="6" />
<idx index="7" />
</child>
</root>
Twój czas i pomoc jest bardzo ceniona.