Java XML Document to String DOMaXML(Document doc, String nome)

Here you can find the source of DOMaXML(Document doc, String nome)

Description

DO Ma XML

License

Open Source License

Declaration

public static void DOMaXML(Document doc, String nome) 

Method Source Code


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

import org.w3c.dom.*;

import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.dom.DOMSource;

public class Main {
    public static void DOMaXML(Document doc, String nome) {
        try {/*from  www  .ja  va  2s . c o  m*/
            TransformerFactory tf = TransformerFactory.newInstance();
            Transformer t = tf.newTransformer();

            //result entre o transformador e o arquivo
            StreamResult sr = new StreamResult(new File(nome));
            //resource entre o tranformador e o dom
            DOMSource doms = new DOMSource(doc);
            //pasarlle un stream result e un streamSource
            t.setOutputProperty(OutputKeys.INDENT, "yes");
            t.transform(doms, sr);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. documentToString(Document document, Transformer documentTransformer)
  2. DocumentToString(Document dom)
  3. documentToString(final Node node)
  4. documentToString(Node document)
  5. dom2String2(Document document)
  6. domToString(Document document)
  7. domToString(final Document document)
  8. getDocumentAsString(Document doc)
  9. getDocumentAsString(Document doc)