Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

best XML parser in 5.18

by fionbarr (Friar)
on May 21, 2015 at 18:54 UTC ( [id://1127384]=perlquestion: print w/replies, xml ) Need Help??

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

I have perl 5.18. what the best XML parser in the standard distribution? Thanks

Replies are listed 'Best First'.
Re: best XML parser in 5.18
by toolic (Bishop) on May 21, 2015 at 19:10 UTC
      'standard distribution' means comes with 5.18; does not require installing from CPAN. XML::Simple comes with 5.18 also.

        For the Perl 5 project, the "standard distribution" is the "Core" distribution. As toolic pointed out, the Core does not include any XML modules.

        However, there are also packages that may include additional modules beyond what is in the Core. For example, the Perl package for Debian Linux includes modules needed by the Debian Linux distribution. For MS Windows, StrawberryPerl.com and Active Perl both have whatever extra modules their respective package maintainers thought would be useful to include. Exactly which extra modules may change from one package release to the next.

        Why do you want to not to install modules from CPAN?

        Update: Changed domain of StrawberryPerl (it's .com not .org).

Re: best XML parser in 5.18
by ikegami (Patriarch) on May 22, 2015 at 17:12 UTC

    There are no XML parsers in the official Perl distribution.

    XML::Simple is probably the most popular parser, but it's a really poor parser. Its own documentation instructs you not to use it. Other than XML::Simple, the most popular XML parsers are XML::LibXML (a very fast, full-featured parser with a DOM-based interface) and XML::Twig (a reasonably fast full-featured parser with a more Perlish interface).

    I've done extensive benchmarking in the past, and the only one faster than XML::LibXML was XML::Bare[1]. No other was even close. XML::Bare has a number of problems, though. 1) You must decode the document before parsing it. 2) It doesn't support namespaces or namespace prefixes. 3) While it can support virtually all XML formats, there are some it can't. XHTML is one it can't. 3) It's tricky to extract information from the tree (since it has the same somtimes-array-sometimes-elememt problem XML::Simple has).


    1. XML::LibXML was faster at parsing than XML::Bare, but XML::Bare was faster when you also included the time to extract information from the tree. The time taken to strip the prefixes from the elements (since XML::Bare can't handle them) was included in the benchmark.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1127384]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-04-18 02:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found