in reply to pls suggest XML parser in pure Perl?

There is no conformant XML parser in pure Perl. XML::Parser::Lite, included in SOAP::Lite, parses only the subset of XML used by SOAP, and XML::SAX::PurePerl, included in XML::SAX, has problems with nested entities (at least, I haven't tested it exhaustively). There are others (one in XML::Smart I think), but once again they do not cover the entire XML spec.

So either you are willing to ship something that doesn't cover all of XML, or you find a way to distribute a proper parser, XML::Parser or XML::LibXML.

On *nix and OS X it is usually quite easy to get the libraries and XML::Parser or XML::LibXML installed, so often ease of distribution implies "on Windows".As it turns out Activestate Perl comes with XML::Parser (and expat) pre-installed, as it is used by ppm, and the latest version of vanilla perl includes expat and XML::Parser. So maybe it's worth looking into that.

  • Comment on Re: pls suggest XML parser in pure Perl?

Replies are listed 'Best First'.
Re^2: pls suggest XML parser in pure Perl?
by Anonymous Monk on Feb 22, 2008 at 10:28 UTC
    Thanks for your detailed answer! In my case, I have to ship an OS X app with its backed written in perl. Unfortunately OSX does not ship any xml parser for perl (at least with all versions below 10.5.0, I didn't test Leopard yet).

    Since each OS X version ships its own version of perl (and SAX and libxml), and OSX is available for PPC and x86 CPUs, shipping precompiled XML::Parser (for each version of perl and cpu) is not trivial..

    I hope that XML I'll have to support won't use Entities at all.

      Actually if you give the OS X gcc multiple -arch flags it'll automagically create a fat binary that'll run on both. You should be able to twiddle the generated Makefile to pass the extra arguments without too much trouble. Then you could probably get away with a 10.4 and a 10.5 version.

      Another possibility might be to use PAR and make a multi-platform PAR archive with both versions available (again, one for 10.4, one for 10.5).

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.