I have an org.w3c.dom.Element
object passed into my method. I need to see the whole xml string including its child nodes (the whole object graph). I am looking
Simple 4 lines code to get String
without xml-declaration (<?xml version="1.0" encoding="UTF-16"?>
) from org.w3c.dom.Element
DOMImplementationLS lsImpl = (DOMImplementationLS)node.getOwnerDocument().getImplementation().getFeature("LS", "3.0");
LSSerializer serializer = lsImpl.createLSSerializer();
serializer.getDomConfig().setParameter("xml-declaration", false); //by default its true, so set it to false to get String without xml-declaration
String str = serializer.writeToString(node);