I am trying to parse XML as a String. No matter whether or not I'm using the response from a RESTful call or a simple string, i get a null Document when i parse it. i have found several posts telling me to follow the code (below), yet it doesn't seem to work for me. What have i done wrong?
import org.xml.sax.InputSource;
import org.w3c.dom.Document;
...
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
String xml = responseEntity.getBody();
//String xml = "<foo\>";
Document doc = db.parse(new InputSource(new StringReader(xml)));
i followed: In Java, how do I parse XML as a String instead of a file?