Hi everyone, I've read in a few places that libxml2's xmlXPathOrderDocElems can help speed up XPath queries when doing read-only lookups on documents. http://www.xmlsoft.org/html/libxml-xpath.html#xmlXPathOrderDocElems Has anyone tried it? Would it make sense to have a method like .xpath_speedup() or something on the _Element class? Perl LibXML has it: http://search.cpan.org/~shlomif/XML-LibXML-2.0107/lib/XML/LibXML/Document.po... Mentioned here: http://code.activestate.com/lists/perl-xml/8161/
So you see, the greatest performance boost is achieved by indexing the elements and only after that there is a small but noticable benefit of pre-compiling the XPath expressions.
This Zori project (I know nothing about) is using it: https://www.assembla.com/spaces/Zori/wiki https://www.assembla.com/code/Zori/subversion/nodes/372/trunk/src/ens/ens_re...
ens_read_xml_popen( &doc, &ctx, voff_proc, ens_opt ); //This supposedly speeds up XPath evaluation for static documents //Update: not just supposed, but vast improvement for reading (many) walkers xmlXPathOrderDocElems( ctx->doc );
Regards, Paul.