in reply to XML::XPath memory usage

All XML parsers work in one of two ways. They are either tree based or stream based. A tree-based parser will always read in all of your document and will therefore have a large memory footprint for a decent sized XML document[1]. Stream-based parsers look a the document one token at a time and therefore have far smaller memory requirements.

XML::Parser can be used in both modes. From what you're saying, it seems that XML::XPath uses XML::Parser in tree mode. I'm having difficulty thinking how you could build an XPath processor using a stream-based parser. It's probably possible - but I think it would be very hard work. I don't know of any that currently exist.

If you don't like XML::XPath's memory footprint, have you thought about switching to an alternative (i.e. stream-based) approach?

[1] Let me pre-empt mirod's reply and point out that XML::Twig gives you the ability to build smaller trees from part of your XML document.

--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: XML::XPath memory usage
by Jaap (Curate) on Dec 31, 2002 at 12:08 UTC
    If you don't like XML::XPath's memory footprint, have you thought about switching to an alternative (i.e. stream-based) approach?

    I have. But none currently exist (as you say too) so i thought about maybe starting to write one myself (ahum).

    I could build it on top of a SAX or Twig module as you point out. I wonder which would be best.