documentRoot.appendChild(documentElement);
documentElement = document.createElement("year");
documentElement.setTextContent(year);
documentRoot.appendChild(documentElement);
documentElement = document.createElement("month");
documentElement.setTextContent(month);
documentRoot.appendChild(documentElement);
return document;
}
but trying to get the doc as a string produces a partial document
(e.g. "<?xml version="1.0" encoding="UTF-8"?
<response><firstname>DAVE")
private String getXMLString(Document document) throws Exception {
StringWriter swriter = new StringWriter();
TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(swriter);
transformer.transform(source, result);
swriter.close();
return swriter.toString();
}
Any ideas why or how to troubleshoot further? Thanks, - Dave