• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Efficient XML Parser with Xpath

 
Mehul Wani
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic