Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

Re: [jdom-interest] How to optimize xpath in jdom

Anshul Saxena

2006-12-07

Replies:

Hi Deepa,
Perhaps you can use this:

import org.jdom.xpath.XPath
XPath xp = XPath.newInstance("/Root/Parent/Child[name=\"abc\"]/GrandChild");
xp.selectSingleNode(); or xp.valueOf();

Depends on what you want as output.

Note : you will have to include : jaxen-jdom.jar , saxpath.jar & jaxen-core.jar in addition to jdom.jar which you may have already added

On 12/7/06, Deepa Chandrashekaraiah (RBIN/EDM2) <Deepa.Chandrashekaraiah@in.bosch.com> wrote:

Hello,

I am using Xpath available in jdom. The xml file is of 9MB size. It is taking a lot of time to query a simple xpath like:

/Root/Parent/Child[name="abc"]/GrandChild

I am trying to get the value of the "GrandChild" element in the following way:
((Element)org.jdom.xpath.XPath.selectSingleNode(xml_Document, xpath_expression)).getValue();

There are many "Child" elements in my huge xml file of 9MB size. Please let me know to optimize the xpath expression or any other workarounds.

Thanks in advance.
Regards,
Chandra


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com


_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.