Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Element; public class Main { public static Element createElement(String tag) throws Exception { DocumentBuilderFactory oDOMFactory = null; DocumentBuilder oDOMBuilder = null; org.w3c.dom.Document oDOMDocument = null; oDOMFactory = DocumentBuilderFactory.newInstance(); // oDOMFactory.setNamespaceAware(true); oDOMBuilder = oDOMFactory.newDocumentBuilder(); oDOMDocument = oDOMBuilder.newDocument(); Element oElement = oDOMDocument.createElement(tag); return oElement; } }