Here you can find the source of serialise(Node node)
Parameter | Description |
---|---|
node | the XML node |
public static String serialise(Node node)
//package com.java2s; // publish, distribute, sublicense, and/or sell copies of the Software, import java.util.logging.*; import org.w3c.dom.Node; import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; public class Main { final static Logger log = Logger.getLogger("OpenDial"); /**/*w w w. ja v a2 s . co m*/ * Serialises the XML node into a string. * * @param node the XML node * @return the corresponding string */ public static String serialise(Node node) { try { DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance(); DOMImplementationLS lsImpl = (DOMImplementationLS) registry.getDOMImplementation("LS"); LSSerializer serializer = lsImpl.createLSSerializer(); return serializer.writeToString(node); } catch (Exception e) { log.fine("could not serialise XML node: " + e); return ""; } } }