XPath expressions with a SAX parser

Jonathan Stowe jns at gellyfish.com
Tue Mar 13 09:20:46 GMT 2007


On Tue, 2007-03-13 at 10:04 +0100, Luis Motta Campos wrote:
> On Mar 13, 2007, at 9:22 AM, Nik Clayton wrote:
> > Morning all,
> >
> > Is it possible to use XML::XPath (or similar) with a SAX parser?
> >
> > I'm trying to do is retrieve a (small) subset of elements from an  
> > XML document (that may be very large).  XML::XPath works when the  
> > document is small, but fails to scale when the document is very  
> > large (even if the subset of elements I'm trying to retrieve is a  
> > fairly constant size).
> >
> > I'd like to keep using the XPath syntax (because it's nice and  
> > compact), rather than write my own SAX event handler (because that  
> > will be more code).
> >
> > Poking around CPAN doesn't show anything useful, although it's  
> > possible I've missed something given the huge number of XML::*  
> > modules available.
> 
>    Have you looked at http://search.cpan.org/~mirod/XML-DOM- 
> XPath-0.13/XPath.pm ?

I think that will probably suffer from the same problem as it will need
to parse the entire document and build a tree in memory (or rather
XML::DOM will.)

/J\


More information about the london.pm mailing list