Re: [xml] Simple Element+Attribute Lookup with XPath - performance ?
- From: Martin Trappel <0xCDCDCDCD gmx at>
- To: xml gnome org
- Subject: Re: [xml] Simple Element+Attribute Lookup with XPath - performance ?
- Date: Sun, 20 Jul 2008 16:10:55 +0200
-------- Original Message --------
Subject: Re: [xml] Simple Element+Attribute Lookup with XPath -
performance ?
Date: Fri, 18 Jul 2008 08:31:52 +0200
From: 0xCDCDCDCD gmx at
To: xml gnome org
References: <487D89C5 80306 gmx at> <20080717083257 GA16927 flap>
Volker Grabsch wrote:
On Wed, Jul 16, 2008 at 07:40:21AM +0200, Martin Trappel wrote:
<ROOT>
<FOO Name="a">
<BAR Id="2"/>
<BAR Id="1"/>
<BAR Id="4"/>
...
<BAR Id="2345"/>
</FOO>
<FOO Name="b">
...
</FOO>
...
</ROOT>
[...]
Use the xpath search expression 'BAR[ id="4"]' and use the returned nodeset.
While I don't know why this expression is slow, you might want to try
the "id()" or keyref mechanisms. They are very fast because of an
additional index structure. However, this only works properly if your
@id values are unique in the whole document, i.e. among all <FOO>
elements.
Unfortunately they are not.
You could also try to use this XPath expression:
*[ id="4"]
It might be faster if all sub elements of <FOO> are <BAR>s.
Will have to try that, thanks!
I should have explicitly mentioned in my first mail that interestingly
the xmlXPathEvalExpression("BAR", xpc); (in example b) is
lightning-fast, but apparently given a predicate it gets really slow.
Does anyone know what extra kind of work the XPath processor needs to do
for the simple predicate [ id="4"] other than look it up in the
attributes of the BAR elements?
cheers,
Martin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]