in reply to How to parse XML coming from a socket?

I'd suggest a switch to XML::LibXML.

It can accept an XML document in chunks, the way you need it. You get a DOM and SAX parser in one package and can mix access to DOM trees with XPath expressions. The actual XML parsing and document tree storage is all done on the C side, so it's much faster and consumes astonishingly little memory compared with XML::Parser-based modules.

It doesn't get any better than that. I'd been a fan of XML::Twig until I discovered this one. Don't leave home without it.

Makeshifts last the longest.

  • Comment on Re: How to parse XML coming from a socket?

Replies are listed 'Best First'.
Re: Re: How to parse XML coming from a socket?
by mirod (Canon) on Oct 04, 2003 at 18:30 UTC

    This is interesting: I was actually thinking of writing a module similar to XML::DOM::Twig (which is hopelessly out of date BTW), on top of XML::LibXML. It would use as many of XML::LibXML native functions as possible, but add convenience methods from XML::Twig. I found that using XPath in XML::LibXML makes it really easy to access data in the XML tree, but that you then have to use the DOM for modifying it, which is verbose and clumsy.

    Does this make sense, and which methods would you think would be most helpful? For eaxmple I really miss XML::Twig's version of insert when I use the DOM. prefix is another really useful one that can't be done simply.

      To be honest, I have no idea. So far I've had no need to transform existing documents, and mostly need to parse XML documents or occasionaly create ones from scratch. Full XPath support is very helpful to parse; Twig's cut down version doesn't compare. Nevertheless, something along the lines of XML::LibXML::Twig would certainly be handy when I eventually have to deal with transformation type tasks.

      Makeshifts last the longest.

Re: Re: How to parse XML coming from a socket?
by vadim_t (Acolyte) on Oct 04, 2003 at 18:52 UTC

    XML::LibXML looks very good too, thanks!

    So many helpful replies :-) Now I'm going to have to choose one of them, though.