开发者

I need some jar for Java and xml

开发者 https://www.devze.com 2023-01-19 09:35 出处:网络
classical way to handle XML in java is really lengthy and scary. For this purpose i made my own clas开发者_如何学JAVAs which can return me result without giving me more detail like,

classical way to handle XML in java is really lengthy and scary. For this purpose i made my own clas开发者_如何学JAVAs 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?


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.”


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


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):

  • Remove XML Node using java parser

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

  • http://www.eclipse.org/eclipselink/sdo.php
  • http://bdoughan.blogspot.com/2010/09/processing-atom-feeds-with-sdo.html

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:

  • http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html
  • http://bdoughan.blogspot.com/2010/10/how-does-jaxb-compare-to-xstream.html

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
0

精彩评论

暂无评论...
验证码 换一张
取 消