hotshot has asked for the wisdom of the Perl Monks concerning the following question:

morning guys !

Can you recomend on good moduls for pasrsing XML docs (recursively of course)? It's the first time I'm going to use that so I'm not familiar with this turf.

Thanks.

Hotshot

Replies are listed 'Best First'.
Re: XML parsers
by cjf (Parson) on Apr 24, 2002 at 06:45 UTC

    I posted Working with XML a while back and received some excellent suggestions there. XML::Parser is probably your best bet if you're just parsing XML but check the node for other recommendations as well.

      Actually XML::Parser is one of several options (along with XML::LibXML and XML::SAX::PurePerl) if you want to create a module to process XML. Otherwise you should really use a layer on top of it. XML::Parser is pretty tricky and there are now a lot of much easier (and safer) to use modules: XML::Simple (for data-oriented XML), XML::XPath, XML::Twig, XML::GDOME (although the DOM is also tricky to use) or the SAX parsers (XML::LibXML or XML::SAX::PurePerl).

Re: XML parsers
by vek (Prior) on Apr 24, 2002 at 13:24 UTC
    Personally I would go with XML::LibXML as I've had great success with this module. It's fast and you get the added bonus of being able to validate the XML against a DTD. You'll need to grab the libxml2 C library first though.

    -- vek --
Re: XML parsers
by silent11 (Vicar) on Apr 24, 2002 at 13:18 UTC
    I learned alot from this article on XML.com. It gives you some sample XML data and parses it with a few different perl modules. But why go elsewhere? We have a TURORIALS section here at the monastery. check out the XML::Parser tutorial for a quick rundown of how that module works.

    -Silent11
Re: XML parsers
by ferrency (Deacon) on Apr 24, 2002 at 17:14 UTC
    I like XML::Twig myself. Very good if you only care about part of a document at a time. You can use it in tree mode, or use handlers which will automatically be called when portions of the document are parsed.

    Alan