I have an XmlResourceParser instance called xml. When I try to call getText() on a node, as seen in my code, it returns null. This is strange because I can call getName() on the same node it returns the proper value, so the instance is set up properly. Here is my code:
XmlResourceParser xml = context.getResources().getXml(R.xml.thesaurus);
try {
//if (xml.getName().equals("word")) {
xml.next(); //to the first node within
boolean notFound = true;
while (notFound) {
xml.next();
if (xml.getName() != null && xml.getName().equalsIgnoreCase("synonyms")) {
String synonym = xml.getText();
Log.v(TAG, String.valueOf(synonym));
notFound = false; //found
}
}
}
} catch (XmlPullParserException xppe) {
xppe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
Here is my XML, even though there isn't anything wrong with it:
allow
Any help would be appreciated! Thanks!