This code is used to generate a XML document from its String representation. It works fine in my small unit tests, but fails in my actual xml data. The line where it triggers is Document doc = db.parse(is);
Any ideas?
public static Document FromString(String xml)
{
// from http://www.rgagnon.com/javadetails/java-0573.html
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
Document doc = db.parse(is);
doc.normalize();
return doc;
}
catch (Exception e)
{
Log.WriteError("Failed to parse XML", e, "XML.FromString(String)");
return null;
}
}