Re: [Fwd: [Bratislava-pm] XML::LibXML performance]

Petr Pajas <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
On st 10. září 2008, Emmanuel Rodriguez wrote:
> Petr Pajas wrote:
> > Hi,
> >
> > Tim is right. This is also the reason why SAX2 parsing is slow
> > in Perl. As for XPath performance, provided that you do not
> > modify the document significantly during your processing, you
> > may try calling
> >
> > $doc->indexElement;
>
> I tried this one first, but it was done in the second version of
> the script, that one that had all XPath striped. With that script
> there was no improvement since XPath was used only once.
>
> > before you start XPath queries on your document.
> >
> > Another potential for improving XPath performance seemed to me
> > to be in letting the user pre-compile static XPath expressions
> > and reuse them in the pre-compiled form. The API, soon to
> > appear in the SVN, looks like:
> >
> > my $comp_xpath = XML::LibXML::XPathExpression->new($xpath);
>
> This is great and will be highly appreciated. I hope that the the
> pre-compilation of XPath expressions will allows us to interact
> with XML::LibXML::XPathContext or provide some other way to
> define the namespaces to used in the query.

Yes, you will be able to pass the resulting object to any find... 
method of X::L::Node or X::L::XPathContext where you would normally 
pass XPath expression as a string.

Pre-compiling does not resolve namespace prefixes, so you need to 
register them with an XPathContext, as usual.

I have committed the code and documentation a minute ago, so you can 
check out from the SVN and try. Instructions for compiling from SVN 
are in the README file:

http://search.cpan.org/src/PAJAS/XML-LibXML-1.66/README

-- Petr
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.