aspose file tools*
The moose likes XML and Related Technologies and the fly likes Efficient XML Parser with Xpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Efficient XML Parser with Xpath" Watch "Efficient XML Parser with Xpath" New topic
Author

Efficient XML Parser with Xpath

Mehul Wani
Greenhorn

Joined: Mar 18, 2008
Posts: 18
Hi,

I'm parsing a large XML file(of size 3.5 MB) using DOM parser. I'm using relative XPath for processing the XML. However, with DOM, XPath is consuming lot of time(almost a min. for a parent child combination and have 900 such elements) and total time taken is 10 -12 hours for one such file.

Can anyone suggest a good effiicient parser which has similar features of DOM like relative XPath and returning node object on querying with XPath?

Thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
The parser has little to do with the time you are seeing, XPath just takes time. If you want speed you are going to have to work closer to the DOM.

In experiments I did for an article, XPath in Java 1.5 took more than 20 times longer to locate a node than using the DOM methods.

XPath is good for clarity of expression, not raw speed.

Bill
Mehul Wani
Greenhorn

Joined: Mar 18, 2008
Posts: 18
Bill,

Many thanks for the reply.

Do you by any chance know any of good Xpath packages that can work with DOM?

William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
Do a google search for "xpath java performance" to get lots of performance related articles.

Working directly with the org.w3c.dom methods in the standard Java library is not that hard and will naturally be much faster than any xpath implementation because xpath has to use the same methods.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Efficient XML Parser with Xpath