java - org.w3c.dom.ls.LSSerialize - setting text wrapping, indentation size -
I am using the following code to indent a xml document which is provided to me as a string. I am using the jdk implementation of org.w3c.dom.ls , if this is the case. public string format (string xml) {Try {Final InputSource src = New Input Source (New Stringer (XML)); Final node document = DocumentBuilderFactory.newInstance (). NewDocumentBuilder (). Parse (src) .getDocumentElement (); Keep the last boolean declaration = boolean.valof (xml.startsWith ("& lt ;? xml")); // it may be required: System.setProperty (DOMImplementationRegistry.PROPERTY, "com.sun.org.apache.xerces.internal.dom.DOMIfplementationSourceImpl"); Last DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance (); Last DOMImplementationLS impl = (DOMImplementationLS) Registry .getDOMImplementation ("LS"); Last LSSerializer Author = impl.createLSSerializer (); Writer.getDomConfig () SetParameter ("format-beautiful print", boolean. TRUE); // Set it...