XOM (XML Object Model) is a tree based java API for processing XML
by taking the best ideas from SAX and DOM. It is simple, fast and easy to use.
This requires the library xom-1.2.7.jar to be in classpath.
The following example shows creating an XML document with namespace.
/**
* @param args
* @throws IOException
*/ public static void main(String[] args) throws IOException {
String myNameSpace = "http://bethecoder.com";
//Create root element with name space
Element root = new Element("btc:RandomNumbers", myNameSpace);
Document doc = new Document(root);
Random random = new Random();
Element ranEle = null; for (int i = 0 ; i < 10 ; i ++) {
//Child elements in the same name space
ranEle = new Element("btc:Number", myNameSpace);
ranEle.appendChild(String.valueOf(random.nextInt(1729)));
doc.getRootElement().appendChild(ranEle);
}