Understanding JDOM which is a combination of Java and XML

JDOM is open source. It is a Java API that is purely written in Java for Java. With this API in place you can easily work with your XML documents. You can parse them, create them, manipulate them and serialize them the way you want.


_______________________________________________

In one way you can compare the JDOM with the DOM model. In both these models the XML document is represented as a tree structure of elements, attributes, etc.

The Java coding conventions were followed in developing the JDOM. All the methods like, equals(), hashCode(), and toString() are also available in JDOM. The java.util.List is the place where all the elements and their children are stored.

While writing the code to create an element in an XML file, it is straightforward and easy to create it in JDOM. Whereas in the DOM model using the JAXP, you have to create the document object in three steps and then only you can add an element to that object. In JDOM if you want to create a new document object, it is very straight forward and you can write the code as,

Document doc = new Document();

Suppose you want to create a new element 'person' and add a text 'Bill' to it, then you can easily write the code as,

Element root = new Element("person");
root.setText("Bill");

After creating the element you can easily add it to the document object with the code,

doc.setRootElement(root);

It is so easy to work with JDOM. There are lots of examples and tutorials on using JDOM for manipulating XML documents.




_______________________________________________

FREE Subscription

Subscribe to our mailing list and receive new articles
through email. Keep yourself updated with latest
developments in the industry.

Name:
Email:

Note : We never rent, trade, or sell my email lists to
anyone. We assure that your privacy is respected
and protected.

_______________________________________








 

 

FREE Subscription

Stay Current With the Latest Technology Developments Realted to XML. Signup for Our Newsletter and Receive New Articles Through Email.

Name:

Email:

Note : We never rent, trade, or sell our email lists to anyone. We assure that your privacy is respected and protected.

 

 

Add to My Yahoo!

Visit XML Training Material Guide Homepage

 

 

Copyright - © 2004 - 2017 - All Rights Reserved.