Reputation: 7413
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?
Upvotes: 1
Views: 255
Reputation: 149047
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:
Upvotes: 0
Reputation: 13799
Try Apache Digester.Using digester will really simplify your XML parsing.You can refer this link for an example.
Upvotes: 1
Reputation: 14505
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.”
Upvotes: 1