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

Doc to XML 

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 converting an XML document to XML string.

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

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

public class DocToXML {

   @param args
  public static void main(String[] args) {
    Element root = new Element("root");    
    root.appendChild("BE THE CODER");
    Document doc = new Document(root);
    //Convert the constructed document to String
    String result = doc.toXML();


It gives the following output,
File Name  :  OUTPUT


bl  br