Java XML Document Create createDocument(Node node)

Here you can find the source of createDocument(Node node)

Description

create Document

License

Open Source License

Declaration

static public Document createDocument(Node node) throws Exception 

Method Source Code

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

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.dom.DOMResult;

import org.w3c.dom.Document;

import org.w3c.dom.Node;

public class Main {
    static public Document createDocument(Node node) throws Exception {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);//from  w  w  w. jav  a  2  s  .  c  o  m
        Document doc = dbf.newDocumentBuilder().newDocument();
        if (node != null) {
            Transformer t = TransformerFactory.newInstance().newTransformer();
            t.transform(new DOMSource(node), new DOMResult(doc));
        }
        return doc;
    }
}

Related

  1. createDocument(File file)
  2. createDocument(File file)
  3. createDocument(final File file)
  4. createDocument(final String rootName)
  5. createDocument(InputSource is)
  6. createDocument(Node sourceNode)
  7. CreateDocument(Path xml, Path xsd)
  8. createDocument(String content, String charset)
  9. createDocument(String docElt)