Reputation: 12783
I'm trying to parse an XML feed using DOM. When a node looks like this:
<title>'Star Wars' May the force live</title>
the returned XML is only ' and then the parser continues on to the next node.
Here's how I'm parsing it:
NodeList list = node.getChildNodes();
for (int j=0; j<list.getLength(); j++) {
Node innerItem = list.item(j);
String name = innerItem.getNodeName();
if (name.equalsIgnoreCase("title")) {
vo.setTitle(innerItem.getFirstChild().getNodeValue());
}
}
How can I fix this? The code parses fine in Android 4, but fails in Android 2.3.3
Upvotes: 1
Views: 806
Reputation: 3822
Looks like your question is very much similar to this one: android decoding html in xml file
It seems HTML characters break the DOM parser, so it is unable to get the string from the xml entity. There is a HTML function to parse HTML in a string.
TextView tv;
String s = "<quote>'Star Wars' May the force live</quote>";
tv.setText(HTML.fromHtml(s));
Outputs:
"Star Wars" May the force live
However it seems the DOM isn't getting the string to convert, so the following article maybe useful: Using XPATH and HTML Cleaner to parse HTML/XML
Upvotes: 2