tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
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  :  
com/bethecoder/tutorials/xom/tests/DocToXML.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
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();
    System.out.println(result);
  }

}
   

It gives the following output,
File Name  :  OUTPUT


                    Print

   



Books Recommendation

 
 
bl  br