XPath expressions with a SAX parser

dakkar dakkar at thenautilus.net
Tue Mar 13 09:05:18 GMT 2007


Nik Clayton wrote:
> Is it possible to use XML::XPath (or similar) with a SAX parser?

In general, the data model of XPath assumes having the entire tree
accessible directly (i.e. having a DOM in memory). It's possible to
write a lazy XPath evaluator, that would yield results during a SAX
parse, but its' probably not really worth it. See below.

> 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).

XML::Twig. Really, try it. mirod wrote it exactly to handle very large
documents, and to use XPath expressions on them.

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88


More information about the london.pm mailing list