Google
 
   
Login
Username:

Password:


Lost Password?

Register now!
Search
Main Menu
top books
Polls
What do you think about php-deluxe.net?
Excellent!
Cool
Hmm..not bad
What the hell is this?
encyclopedia
recommendation
compare webbrowser
Freenet DSL
Who's Online
8 user(s) are online (8 user(s) are browsing encyclopedia)

Members: 0
Guests: 8

more...
browser tip
Unix Befehle
manual of unix befehle
recommendation!
Sponsored
partner

JDOM

In Computing, JDOM is a Java-based document object model for XML that integrates with Document Object Model (DOM) and Simple API for XML (SAX) and uses parsers to build the document. It was designed specifically for the Java platform so that it can take advantage of its language features. The name JDOM is a pseudo-acronym.

= Examples =

Suppose the xml file foo.xml which is:

One can parse the XML file into a tree of Java objects with JDOM, like:

SAXBuilder builder = new SAXBuilder (); Document doc = builder.build (new FileInputStream ( foo.xml )); Element root = doc.getRootElement (); // root.getName () is shop // root.getAttributeValue ( name ) is shop for geeks // root.getAttributeValue ( location ) is Tokyo, Japan // root.getChildren () is a java.util.List object who has 3 Element objects.

As a converse, one can construct a tree of elements, then generate a XML file from it, like:

Element root = new Element ( shop ); root.setAttribute ( name , shop for geeks ); root.setAttribute ( location , Tokyo, Japan ); Element item1 = new Element ( computer ); item1.setAttribute ( name , iBook ); item1.setAttribute ( price , 1200$ ); root.addContent (item1); // do the similar for other elements XMLOutputter outputter = new XMLOutputter (); outputter.output (new FileOutputStream ( foo2.xml ));

= See Also =

*Java Community Process

= External links =

*[http://jdom.org/ JDOM home page] *[http://www.jcp.org/en/jsr/detailid=102 JSR 102] *[http://dom4j.org/ dom4j] another Java-based XML library