Here you can find the source of getStringFromXMLDocument(Document doc)
Parameter | Description |
---|---|
doc | a parameter |
public static String getStringFromXMLDocument(Document doc)
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; public class Main { /**//ww w . j a v a 2 s . com * Serializes an XML document to a string * * @param doc * @return */ public static String getStringFromXMLDocument(Document doc) { DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation(); LSSerializer lsSerializer = domImplementation.createLSSerializer(); return lsSerializer.writeToString(doc); } }