Java Tutorial - Java Script : Processing XML with XOM

Java Tutorial - Java Script : 

 Processing XML with XOM

One of the most important skills you can develop as a Java programmer is the ability to find suitable packages and classes that can be employed in your own projects. For obvious reasons, making use of a well-designed class library is much easier than developing one on your own. Although Sun’s Java class library contains thousands of well-designed classes that cover a comprehensive range of development needs, the company isn’t the only supplier of packages that may prove useful to your efforts.
Dozens of Java packages are offered by other companies, groups, and individuals under a variety of commercial and open source licenses. Some of the most notable come from Apache Jakarta, a Java development project of the Apache Software Foundation that has produced the web application framework Struts, the Log4J logging class library, and many other popular libraries.
Another terrific open source Java class library is the XOM library, a tree-based package for XML processing that strives to be simple to learn, simple to use, and uncompromising in its adherence to well-formed XML. The library was developed by the programmer and author Elliotte Rusty Harold based on his experience with Sun’s XML processing packages and other efforts to handle XML in Java.The project was originally envisioned as a fork of JDOM, a popular tree-based model for representing an XML document. Harold has contributed code to that open source project and participated in its development. Instead of forking the JDOM code, Harold decided to start from scratch and adopt some of its core design principles in XOM.
The library embodies the following principles:
XML documents are modeled as a tree with Java classes representing nodes on the tree such as elements, comments, processing instructions, and document type definitions. A programmer can add and remove nodes to manipulate the document in memory, a simple approach that can be implemented gracefully in Java.
All XML data produced by XOM is well-formed and has a well-formed namespace.Each element of an XML document is represented as a class with constructor methods.
Object serialization is not supported. Instead, programmers are encouraged to use XML as the format for serialized data, enabling it to be readily exchanged with any software that reads XML regardless of the programming language in which it was developed.
The library relies on another XML parser to read XML documents and fill trees instead of doing this low-level work directly. XOM uses a SAX parser that must be downloaded and installed separately. Right now, the preferred parser is Apache Xerces 2.7.1.XOM is available for download from the web address http://www.cafeconleche.org/ XOM. The most current version at this writing is 1.1, which includes Xerces 2.7.1 in its distribution.
After you have downloaded XOM and added its packages to your system’s Classpath, you’re ready to begin using XOM. The full installation instructions are available from the XOM and Xerces websites. The classes are distributed as JAR archive files—xom-1.1.jar, xercesImpl.jar, and xmlapis. jar. These files should be added to your system’s Classpath environment variable so that your Java programs can use XOM classes.