I have an input stream which is being converted to XML, and read. When I get down to some text elements in the XML, they are truncated. I believe the parser is dropping everything after escaped HTML such as & Here is the code getting the input stream and then getting the text element.
String hvurl = "https://www.mysite.com/api/a/" + answerId;
in = OpenHttpConnection(hvurl);
Document doc = null;
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
doc = db.parse(in);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
...
//Now when I get the text element, it's truncated
//---get the <varietalTitle> elements under the <varietal>
// element---
NodeList varietalTitleNodes =
(varietalElement).getElementsByTagName("varietaltitle");
//---convert a Node into an Element---
Element varietalTitleElement = (Element) varietalTitleNodes.item(0);
//---get all the child nodes under the <varietaltitle> element---
NodeList varietalTitleTextNodes =
((Node) varietalTitleElement).getChildNodes();
//---retrieve the text of the <varietalid> element---
strVarietalTitle = ((Node) varietalTitleTextNodes.item(0)).getNodeValue();