tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 XML > XOM > Namespace


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.

File Name  :  
Author  :  Sudhakar KV
Email  :  [email protected]
package com.bethecoder.tutorials.xom.tests;

import java.util.Random;

import nu.xom.Document;
import nu.xom.Element;
import nu.xom.Serializer;

public class NamespaceTest {

   @param args
   @throws IOException 
  public static void main(String[] argsthrows IOException {
    String myNameSpace = "";
    //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 = ; i < 10 ; i ++) {
      //Child elements in the same name space
      ranEle = new Element("btc:Number", myNameSpace);
    //Pretty print
    Serializer serializer = new Serializer(System.out, "UTF-8");


It gives the following output,
File Name  :  OUTPUT



Books Recommendation

bl  br