tags:

views:

83

answers:

6

classical way to handle XML in java is really lengthy and scary. For this purpose i made my own class which can return me result without giving me more detail like,

myXML mx=new myXML("filename");
:
mx.getAll("node name");
mx.getFirst("node name");
:

I had completed it 80%. But unfortunately, i had lost it in PC crash.

is there any jar under GPL or apache license which provides facility to read & write XML in simplest way?

A: 

You could try jdom.

Emil H
A: 

I have a very good experience with Simple and XStream both. Easy to use, and very good examples provided.

Adeel Ansari
Blaise Doughan
+2  A: 

JDOM is simple API for parsing, creating, manipulating, and serializing XML documents in Java. API's you mentioned in your question are supported by JDOM (Other than many more useful API's).

Checkout JDOM documentation/book chapter here for more reading:

http://www.jdom.org/downloads/docs.html

http://www.cafeconleche.org/books/xmljava/chapters/ch14.html

Following are lines from http://www.jdom.org/docs/oracle/jdom-part1.pdf

So what’s the point of JDOM (Java Document Object Model), and why do developers need it? JDOM is an open source library for Java-optimized XML data manipulations. Although it’s similar to the World Wide Web Consortium’s (W3C) DOM, it’s an alternative document object model that was not built on DOM or modeled after DOM. The main difference is that while DOM was created to be language-neutral and initially used for JavaScript manipulation of HTML pages, JDOM was created to be Java-specific and thereby take advantage of Java’s features, including method overloading, collections, reflection, and familiar programming idioms. For Java programmers, JDOM tends to feel more natural and “right.”

YoK
A: 

Try Apache Digester.Using digester will really simplify your XML parsing.You can refer this link for an example.

Emil
A: 

For your use case you may be interested in the javax.xml.xpath APIs available in the JDK. For an example see one of my answers to another question (below):

You may also prefer Service Data Objects (SDO). It is a generic data structure for representing XML data. For more information see:

When parsing XML I recommend using the standard technologies: StAX, SAX, DOM, and JAXB. An implementation of each is included in the. JDK and alternate open source implementations are available offering improved performance and extended features, such as MOXy JAXB's XPath based mapping:

The advantage of the standard libraries is that they all work together:

  • StAX, SAX, and DOM are all valid inputs/outputs for JAXB
  • StAX, SAX, DOM, and JAXB are all compatible with javax.xml.transform libraries
  • StAX, SAX, DOM, and JAXB are all compatible with javax.xml.xpath libraries
  • StAX, SAX, DOM, and JAXB are all compatible with javax.xml.validation libraries
  • JAXB is the binding layer for two Web Service standards: JAX-WS and JAX-RS
Blaise Doughan
A: 

Finally, I had made my own API using basic features of dom4j. Its not completed. But seems to be complet in next some days.

I suppose i can build it with basic features provided by java itself.

Thanks for all of your support

articlestack