Here you can find the source of parseDocumentIntoStringXML(Document document)
Parameter | Description |
---|---|
document | Document object to be parsed |
public static String parseDocumentIntoStringXML(Document document) throws TransformerConfigurationException, TransformerException
//package com.java2s; //License from project: Open Source License import java.io.StringWriter; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Document; public class Main { /**/*from w w w .j a va 2s .c o m*/ * Converts a Document into String representation * UTF-8 conversion * @param document Document object to be parsed * @return String representation of xml content */ public static String parseDocumentIntoStringXML(Document document) throws TransformerConfigurationException, TransformerException { StringWriter output = new StringWriter(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(document), new StreamResult(output)); String newObjectResourceXML = output.toString(); return newObjectResourceXML; } }