• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

What is the best (and easiest) XML parser to use for a Java class that will be deployed using jdk1.5.0_12.

What is the best (and easiest) XML parser to use for a Java class that will be deployed using jdk1.5.0_12.  It will be deployed under a JBoss environment but should preferably not be server specific.
0
lasutton
Asked:
lasutton
  • 3
  • 3
  • 2
1 Solution
 
CEHJCommented:
(both exist in Java 5)
0
 
lasuttonAuthor Commented:
Can you point me to any sample classes that use either of these parsers?  i.e.: a class that reads one or two elements from an XML document (or String included in the class that is moved into the XML document).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
msmolyakCommented:
Are you looking for an actual parser or for an easy-to-use API to parse an XML document? If you are looking for the latter, I would suggest using JDOM, an alternative to DOM API you would have to use if you were to go with JDK XML parsing API.

http://www.jdom.org/

JDOM's mission is to make API for parsing, traversing and building XML documents simpler that that afforded by W3C DOM API.

Some JDOM usage examples:

http://www.cafeconleche.org/books/xmljava/examples/14/index.html


Michael
0
 
lasuttonAuthor Commented:
What I am looking for at this point is an easy way to traverse and search for specific elements and attributes in an XML document that is less than 16k in size.  Basically I need to be able to read the document as if I would try to look for records in a database with an index with multiple keys.
0
 
lasuttonAuthor Commented:
...something along the lines of xPath type search capabilities but that can be built within the Java class.
0
 
msmolyakCommented:
XPath is indeed the way to access directly the elements and nodes of the parsed XML document. JDom supports XPath traversal and searches:

http://www.onjava.com/pub/a/onjava/2005/01/12/xpath.html

http://javaboutique.internet.com/tutorials/jdom&/

Michael
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now