• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

XML parsing performance

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have been researching for the last month on what tools to use and libraries for parsing xml and performing certain business logic on the xml data in java before outputting to a flat file. I have come up with using JAXP, Xerces, JDOM and XPATH with Jaxen to traverse the JDOM tree.

Is this a suitable framework do you think before i start developing? And is there a performance issue creating a new instance of XPath every time i need a new expression or predicate to select a value from the JDOM tree?

Thanks,
Shane.
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're planning to use XPath for nearly everything, you may be able to reduce your dependencies on external libraries by using the built-in XPath and DOM support from Java 5 and better. Whether this is a good thing is up to you; there are other nice features in JDOM, dom4j and XOM that provide reasons to use them instead.

I wouldn't expect a significant performance impact on parsing the XPath expressions every time unless you're calling them in a loop.
 
Shane Lee
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply Carey.

I am using Java5, so i know i can use xpath and dom from JAXP but JDOM like you said has some nice features for retrieving values from the JDOM tree and Xpath and Jaxen is the libraries I need to use with JDOM.

I see that there is other tools such as dom4j and XOM but i guess you have to pick one way! its quicker i guess to use xpath expressions or xquery to look at certain xml values to output to a flat file format, i dont want to do anything too fancy so i guess ill run with this?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The virtue of XPath / XQuery is clarity of expression and reducing the amount of code you have to write, NOT speed.

I did some simple experiments comparing XPath evaluation with code using the org.w3c.dom methods, XPath was much much slower. Hardly surprising when you consider that it has to translate the path expression AND use the same dom methods.

Unless this operation has to be done many times, I would go with clarity.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic