Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best XML Parsing Tool?

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I would like to know that which open source(free)tool or APIs is best for XML parsing in terms of simplicity, time to write code, flexibility(If XML or schema changes) etc. I am confuse b/w Castor, JAXB, JDOM, Digaster.
Please help me out.
Thanks a lot.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In terms of simplicity, just use the packages built in to the standard Java library ever since Java 1.4 - this avoids getting tangled up in classpath issues, distribution of jar files to customers, etc.
Bill
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry but what you want to say William?
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rathi ji:
sorry but what you want to say William?


If I understood right, I think William said "if simplicity is your measuring scale, use JDK 1.4 for parsing XML".
Thanks.

- m
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly! Either Java 1.4 or 1.5 has a perfectly adaquate XML parsing library.
What is your XML parsing problem? XML is used for everything from simple configuration files (as in Tomcat) to truly monsterous gigbyte data files, so there is no general answer.
Bill
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK William, I got your point.
My requirement are:
1] I just need to unmarshal(read) XML file.
2] XML file is reasonably complex like have depth upto 5 level, some elements may have up to two attributes...
3] Time to write parser code should not take much time.
4] Performance is not really an issue because, I will parse it only once during whole life cycle of project.
5] Tool should be easy to learn like JDOM.

Now can you tell me, which one will be good for me?
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13064
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The standard library should handle this easily and there are plenty of tutorials. I don't use JDOM or Digester because it is much easier for my clients to stick to absolutely standard Java installations.
Using the standard library, once you have a Document (org.w3c.dom.Document) in memory you can use the various methods in the Node and Element classes (org.w3c.dom package) to extract attributes and element content. Study the table in the Node JavaDocs that tells what the various types of XML Node have for values.
If I was starting fresh in this field and did not want to go into detail, I would look at Digester which seems to be designed for this sort of configuration file.
Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic