Fastest XML parser for Perl

Posted on 2006-04-25
Last Modified: 2012-05-05
My perl application is doing a lot of xml file input and output, and I'm finding that the bottleneck in the application is the XML parsing. I'm looking for advice on what is the most efficient XML parsing module is, and what I can do to optimize XML reading/writing in general.

Currently, I'm using XML::Simple, with XML::SAX installed. Here is a look at my dproffpp output currently:

%Time ExclSec CumulS #Calls sec/call Csec/c  Name
 15.3   1.476  1.816  49365   0.0000 0.0000  XML::Simple::collapse
 13.3   1.287  2.459 132588   0.0000 0.0000  XML::SAX::Expat::_handle_char
 11.8   1.135  2.805  49365   0.0000 0.0001  XML::SAX::Expat::_handle_start
 10.0   0.968  7.429    515   0.0019 0.0144  XML::Parser::Expat::ParseStream
 9.46   0.910  1.179  49365   0.0000 0.0000  XML::SAX::Expat::_handle_end
 8.31   0.799  0.799 132588   0.0000 0.0000  XML::Simple::characters
 7.25   0.697  0.697  49365   0.0000 0.0000  XML::Simple::start_element
 4.74   0.456  1.172 132588   0.0000 0.0000  XML::SAX::Base::characters
 4.54   0.437  0.437  49365   0.0000 0.0000  XML::NamespaceSupport::_get_ns_details
 3.00   0.289  0.308  44287   0.0000 0.0000  XML::Simple::array_to_hash
 2.26   0.217  0.217  49365   0.0000 0.0000  XML::NamespaceSupport::push_context
 1.93   0.186  0.205   5395   0.0000 0.0000  Params::Validate::_validate
 1.85   0.178  0.323   3378   0.0001 0.0001  DateTime::TimeZone::new
 1.79   0.172  0.853  49365   0.0000 0.0000  XML::SAX::Base::start_element
 1.49   0.143  0.580  49365   0.0000 0.0000  XML::NamespaceSupport::process_element_name
Question by:timdr
    LVL 4

    Accepted Solution

    One of the fastes ways of parsing XML ist event based with XML::Sax

    See Also:
    LVL 84

    Expert Comment

    What kind of processing do you need to do on the input and output?
    If you do not need full XML parsing, there may be some short cuts you could take.
    LVL 1

    Author Comment

    I don't know if I can do anything but full XML parsing, but i will definitely look into these. What about for regular full xml parsing, is there anythign faster then what I'm using? The reason I ask is because I just recently found that installing XML::SAX greatly increased the speed of things, without any change in code (still using XML::Simple), so I'm trying to find anything else I can install that would help.

    If not, I'll see what I can do about the event based parsing.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
    In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now