Java XML Document to String getStringFromDoc(org.w3c.dom.Document doc)

Here you can find the source of getStringFromDoc(org.w3c.dom.Document doc)

Description

Prints a DOM document to XML using DOM Load and Save's LSSerializer.

License

Open Source License

Parameter

Parameter Description
doc a parameter

Return

xml output

Declaration

public static final String getStringFromDoc(org.w3c.dom.Document doc) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.ls.DOMImplementationLS;

import org.w3c.dom.ls.LSSerializer;

public class Main {
    /**//from  w ww . j  a  v  a2s .co  m
     * Prints a DOM document to XML using DOM Load and Save's LSSerializer.
     *
     * @param doc
     * @return xml output
     * @see LSSerializer
     */
    public static final String getStringFromDoc(org.w3c.dom.Document doc) {
        DOMImplementationLS domImplementation = (DOMImplementationLS) doc.getImplementation();
        LSSerializer lsSerializer = domImplementation.createLSSerializer();
        return lsSerializer.writeToString(doc);
    }
}

Related

  1. getDocumentAsString(Document doc)
  2. getDocumentAsString(Document document)
  3. getDocumentAsString(Node node, boolean prettyXml)
  4. getDocumentAsString(Resource resource)
  5. getString(Document document)
  6. getStringFromDocument(Document doc)
  7. getStringFromDocument(Document doc)
  8. getStringFromDOM(Document doc)
  9. getStringFromDomDocument(org.w3c.dom.Document doc, org.w3c.dom.Document xslt)