create XML Document - Java XML

Java examples for XML:DOM Document

Description

create XML Document

Demo Code


//package com.java2s;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;

public class Main {
    public static Document createDocument() {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();// w ww  . ja v a2 s . com
        DocumentBuilder builder = null;
        try {
            builder = factory.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
        return builder.newDocument();
    }
}

Related Tutorials