How to request data from a lazily-created tree structure ?

méchoui laurent.ploix at gmail.com
Sat Aug 2 12:26:50 EDT 2008


On 17 juin, 13:53, méchoui <laurent.pl... at gmail.com> wrote:
> On Jun 17, 9:08 am, "Diez B. Roggisch" <de... at nospam.web.de> wrote:
>
>
>
> > > Yes, I need to make sure my requests are properly written so that the
> > > generic XPath engine does not need all the structure in memory.
>
> > > There are quite a few cases where you really don't need to load
> > > everything at all. /a/b/*/c/d is an example. But even with an example
> > > like /x/z[last()]/t, you don't need to load everything under the
> > > every /x/z nodes. You just need to check for the latest one, and make
> > > sure there is a t node under it.
>
> > > Anyway, if I need to make requests that need all the data... that
> > > means that the need for lazy instantiation of nodes disappears,
> > > right ?
>
> > Yes. And unless you have memory-constraints I have to admit that I
> > really doubt that the parsing overhead isn't by far exceeded by the
> > network latency.
>
> > Diez
>
> Do you know if there is such XPath engine that can be applied to a DOM-
> like structure ?
>
> One way would be to take an XPath engine from an existing XML engine
> (ElementTree, or any other), and see what APIs it calls... and see if
> we cannot create a DOM-like structure that has the same API. Duck
> typing, really...

I have something that works. http://lauploix.blogspot.com/2008/07/xpath-for-my-trees.html
It has the pro and cons of the ElementTree 1.3 XPath engine, but it
works quite nice.

Laurent Ploix



More information about the Python-list mailing list