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.


In reply to Re: best XML parser in 5.18 by ikegami
in thread best XML parser in 5.18 by fionbarr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.