Last active
August 29, 2015 13:57
-
-
Save xkr47/9595446 to your computer and use it in GitHub Desktop.
Eclipse detail formatters for org.w3c.dom.*
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// org.w3c.dom.Node | |
org.w3c.dom.bootstrap.DOMImplementationRegistry registry = org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(); | |
org.w3c.dom.ls.DOMImplementationLS impl = (org.w3c.dom.ls.DOMImplementationLS) registry.getDOMImplementation("XML 3.0 LS 3.0"); | |
org.w3c.dom.ls.LSSerializer serializer = impl.createLSSerializer(); | |
((org.w3c.dom.DOMConfiguration) serializer).setParameter("xml-declaration", Boolean.FALSE); | |
java.io.StringWriter out = new java.io.StringWriter(); | |
org.w3c.dom.ls.LSOutput output = impl.createLSOutput(); | |
output.setCharacterStream(out); | |
serializer.write(this, output); | |
return out.toString(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// org.w3c.dom.NodeList | |
org.w3c.dom.bootstrap.DOMImplementationRegistry registry = org.w3c.dom.bootstrap.DOMImplementationRegistry.newInstance(); | |
org.w3c.dom.ls.DOMImplementationLS impl = (org.w3c.dom.ls.DOMImplementationLS) registry.getDOMImplementation("XML 3.0 LS 3.0"); | |
org.w3c.dom.ls.LSSerializer serializer = impl.createLSSerializer(); | |
((org.w3c.dom.DOMConfiguration) serializer).setParameter("xml-declaration", Boolean.FALSE); | |
java.io.StringWriter out = new java.io.StringWriter(); | |
org.w3c.dom.ls.LSOutput output = impl.createLSOutput(); | |
output.setCharacterStream(out); | |
if (this instanceof org.w3c.dom.Node) { | |
serializer.write(this, output); | |
} else for (int i=0; i<getLength(); ++i) { | |
org.w3c.dom.Node n = item(i); | |
serializer.write(n, output); | |
} | |
return out.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to drop the xml declaration