remove xml declaration from the generated xml document using java

Posted by flash on Stack Overflow See other posts from Stack Overflow or by flash
Published on 2010-01-25T15:42:17Z Indexed on 2010/12/25 7:54 UTC
Read the original article Hit count: 422

Filed under:
|
|
String root = "RdbTunnels";
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.newDocument();
Element rootElement = document.createElement(root);
document.appendChild(rootElement);   

OutputFormat format = new OutputFormat(document);
format.setIndenting(true);


XMLSerializer serializer = new XMLSerializer(System.out, format);
serializer.serialize(document);

gives the result as following

<?xml version="1.0" encoding="UTF-8"?>
<RdbTunnels/>

but I need to remove the xml declaration from the output how can I do that

© Stack Overflow or respective owner

Related posts about java

Related posts about Xml