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

Is there an XML parser that is written in pure Perl? Slow is ok.

Almost all the XML modules require XML::Parser or another XML module that uses C code. One of the restrictions of my project is that we can only use non-standard (read: not included with the base Perl installs) modules that are pure Perl.

We just went to a pretty simple XML based config file that I now need to parse. I can write my own from scratch, but that goes against the Perl covenant of reusing existing code, when available.

Replies are listed 'Best First'.
Re: Seeking Pure Perl XML Parser
by Zaxo (Archbishop) on Sep 27, 2002 at 23:30 UTC

    XML::SAX::PurePerl. I think this is the first time I've seen anyone insist on non-core modules ;-)

    After Compline,
    Zaxo

      Right now, none of XML modules are technically part of the core. If you use ActiveState, that's a different story, since XML::Parser and SOAP::Lite are installed by default.
      I guess it means "we can only use non-standard modules if they are pure Perl" :)
      Sorry, I worded that wrong. I mean that if we are to use any non-core modules, they have to be pure perl. :0
Re: Seeking Pure Perl XML Parser
by mirod (Canon) on Sep 28, 2002 at 05:32 UTC

    You can use either XML::Parser::Lite or XML::SAX::PurePerl, but be aware that they both have limitations. Neither of them does entity replacement for example (patches welcome ;--).

    If you are using ActiveState build then XML::Parser is installed (PPM uses it), so you can use all of the Pure-Perl modules based on it: XML::Simple, XML::DOM, XML::Twig, XML::XPath...

      The project we are working on have to run on AIX, HPUX, Solaris, Linux, Widows, MacOX and potentially other Un*x platforms from the same Perl code (three chears for portable Perl!).

      So this means that I have to go with either modules that are common to all these platforms, or use modules that can be untared with the the project's Perl code.

      XML::Parser::Lite or XML::SAX::PurePerl meet these requirements, I'll find out soon whether they do the trick.

      Thanks! ;)