Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.sun.org.apache.xml.internal.serialize.XMLSerializer;

public class Main {
    public static void main(String[] argv) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

        DocumentBuilder loader = factory.newDocumentBuilder();

        Document document = loader.newDocument();

        Element order = document.createElement("order");
        document.appendChild(order);

        XMLSerializer serializer = new XMLSerializer();
        serializer.setOutputCharStream(new java.io.FileWriter("order.xml"));
        serializer.serialize(document);

    }
}