[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Fastest XML parser for Perl

Posted on 2006-04-25
Medium Priority
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

Accepted Solution

ps15 earned 2000 total points
ID: 16539435
One of the fastes ways of parsing XML ist event based with XML::Sax

See Also:
LVL 85

Expert Comment

ID: 16539507
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.

Author Comment

ID: 16539638
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
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…
Six Sigma Control Plans
Suggested Courses

834 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