Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Perl Only XML Parser?

by plmc (Acolyte)
on Aug 16, 2004 at 20:05 UTC ( #383433=perlquestion: print w/ replies, xml ) Need Help??
plmc has asked for the wisdom of the Perl Monks concerning the following question:

Folks: My research indicates that most if not all of the Perl XML parsers out there require James Clarks Expat module which in turn is based on (or is) some compiled C code. I'm all set with ActiveState on Windows boxes. However I'm writing an application that will need to be run on (AIX, Solaris, & Linux) boxes, potentially for hundreds of servers. Thus I won't be able to compile my own Expat and distribute it. Cutting to the chase... Is there Perl Only XML Parser out there. Thanks plmc

Comment on Perl Only XML Parser?
Re: Perl Only XML Parser?
by VSarkiss (Monsignor) on Aug 16, 2004 at 20:11 UTC

    The only one I know about is XML::SAX::PurePerl. I haven't used it, though, so I can't say anything about it.

Re: Perl Only XML Parser?
by dragonchild (Archbishop) on Aug 16, 2004 at 20:13 UTC
    XML::SAX::PurePerl is PurePerl, if not completely full-featured.

    As for claiming you can't compile expat on AIX, Solaris, and Linux ... most (if not all) of those OSes come with expat already installed. (Not so sure about AIX, but Solaris and Linux usually do.) So, it's just a matter of installing XML::Parser (which will be a problem only on AIX because of the need to install gcc as well - don't trust IBM's C compiler - it sucks).

    Oh - as an unrelated note - are you planning on making sure you have the right compilation of Perl on each of these boxes? AIX boxes sometime come pre-installed with Perl4. Solaris boxes usually come pre-installed with Perl5.6.0, which is buggy. RedHat comes installed with a Perl5.8.0 that has threading compiled in, which is a performance hit if you don't need it.

    In other words - you will want to compile your own Perl for each of these setups.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

      RedHat and perl 5.8.0 can also have unicode bugs - potientially in issue with xml parsing

Re: Perl Only XML Parser?
by Joost (Canon) on Aug 16, 2004 at 20:17 UTC
Re: Perl Only XML Parser?
by thor (Priest) on Aug 16, 2004 at 20:17 UTC
    Perhaps I'm missing something, but wouldn't it be easier to obtain expat for your *nix boxes given the availabiltiy of C compliers on those platforms? Also, a lot (if not all) of them have package managers (Red Hat has rpm, Debian has apt, etc...) for which a pre-compiled version of expat should be available. I've been wrong before, though. *shrug*

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    With all of us waiting, your kingdom will come

Re: Perl Only XML Parser?
by Anonymous Monk on Aug 17, 2004 at 01:51 UTC
Re: XML::Mini
by Eyck (Priest) on Aug 17, 2004 at 11:23 UTC
    You could try XML::Mini, but that would be wise only if you're working with smaller documents or you've got 'sophisticated' needs.

    XML::Mini provides very simple mapping between hashes and XML, this dramatically reduces amount of XML-related code in your app ( at least my experiences suggests so - this makes my code wrangle only with logic, and xml-parsing and generating takes only few lines )

    Another thing I found, that is not based on Expat is LibXML, it seems that it's got cleaner interface then most other XML libs outthere, and claims to work way better with 'modern' stuff like XPath etc..

    But getting back to XML::Mini, I like it very much, but may not fit all uses ( it doesen't do any DTD validation nor any other funky stuff )

    use XML::Mini::Document; my $xmlDoc = XML::Mini::Document->new(); $xmlDoc->parse($string); my $xmlHash = $xmlDoc->toHash(); my $c = $xmlHash->{'container'}; my $body = $c->{'body'};
Re: Perl Only XML Parser?
by mirod (Canon) on Aug 17, 2004 at 13:50 UTC

    The perl-only XML parsers I have looked at are:

    • XML::SAX::PurePerl, included in XML::SAX, which can be used by all the SAX based modules, including XML::Simple. It works reasonably well, but will not process external entities.
    • XML::Parser::Lite, included in SOAP::Lite, which emulates the XML::Parser interface. It only parses the subset of XML used by SOAP though (eg no DTD)
    • XML::Stream::Parser, included in XML::Stream, which only parses the subset of XML used in Jabber messages.

    As you see none of them is a complete XML parser, so you might want to check if they work for the kind of XML you have to deal with (and for the kind of XML that you might have to deal with in the future!).

    2 other comments: some of the XML modules are based on libxml2 instead of expat (XML::LibXML for example). And I don't know about AIX, but at least for Solaris you can get expat as a pre-compiled package.

      For AIX, you can go here, or sometimes there

      ---------------------------
      Dr. Mark Ceulemans
      Senior Consultant
      BMC, Belgium
Re: Perl Only XML Parser?
by Anonymous Monk on Aug 17, 2004 at 14:30 UTC
    Thanks for the input, I will test a few of the offered solutions to see what will fit best. Primarily I just need to parse the xml's to pull config information to verify that installed applications meet security baselines. The reason I wanted to avoid compiling or installing precompiled Expat is corp security, and admin folks get real nervous when when one wants to change their base install. I'm leaning towards SAX:: and Simple, or XML mini. thanks again
Re: Perl Only XML Parser?
by ambrus (Abbot) on Jun 05, 2006 at 20:30 UTC

    You don't want a perl-only XML parser. Programs parsing XML are slow enough as is. It would be unbearably slow with a perl-only parser. (I once tried parsing XML with rexml, an xml parser implemented in pure ruby. It was SLOW.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://383433]
Approved by VSarkiss
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-10-26 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (153 votes), past polls