Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 811035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:58:46+00:00 2026-05-15T00:58:46+00:00

Summary : I am looking a fast XML parser (most likely a wrapper around

  • 0

Summary: I am looking a fast XML parser (most likely a wrapper around some standard SAX parser) which will produce per-record data structure 100% identical to those produced by XML::Simple.

Details:

We have a large code infrastructure which depends on processing records one-by-one and expects the record to be a data structure in a format produced by XML::Simple since it always used XML::Simple since early Jurassic era.

An example simple XML is:

<root>
    <rec><f1>v1</f1><f2>v2</f2></rec>
    <rec><f1>v1b</f1><f2>v2b</f2></rec>
    <rec><f1>v1c</f1><f2>v2c</f2></rec>
</root>

And example rough code is:

sub process_record { my ($obj, $record_hash) = @_; # do_stuff }
my $records = XML::Simple->XMLin(@args)->{root};
foreach my $record (@$records) { $obj->process_record($record) };

As everyone knows XML::Simple is, well, simple. And more importantly, it is very slow and a memory hog—due to being a DOM parser and needing to build/store 100% of data in memory. So, it’s not the best tool for parsing an XML file consisting of large amount of small records record-by-record.

However, re-writing the entire code (which consist of large amount of “process_record”-like methods) to work with standard SAX parser seems like an big task not worth the resources, even at the cost of living with XML::Simple.

I’m looking for an existing module which will probably be based on a SAX parser (or anything fast with small memory footprint) which can be used to produce $record hashrefs one by one based on the XML pictured above that can be passed to $obj->process_record($record) and be 100% identical to what XML::Simple’s hashrefs would have been.

I don’t care much what the interface of the new module is; e.g whether I need to call next_record() or give it a callback coderef accepting a record.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T00:58:47+00:00Added an answer on May 15, 2026 at 12:58 am

    XML::Twig has a simplify method which you can call on a XML element which according to docs says:

    Return a data structure suspiciously similar to XML::Simple’s

    Here is an example:

    use XML::Twig;
    use Data::Dumper;
    
    my $twig = XML::Twig->new(
        twig_handlers => {
            rec => \&rec,
        }
    )->parsefile( 'data.xml' );
    
    
    sub rec {
        my ($twig, $rec) = @_;
        my $data = $rec->simplify;
        say Dumper $data;
        $rec->purge;
    }
    

    NB. The $rec->purge cleans out the record immediately from memory.

    Running this against your XML example produces this:

    $VAR1 = {
              'f1' => 'v1',
              'f2' => 'v2'
            };
    
    $VAR1 = {
              'f1' => 'v1b',
              'f2' => 'v2b'
            };
    
    $VAR1 = {
              'f1' => 'v1c',
              'f2' => 'v2c'
            };
    

    Which I hope is suspiciously like what comes out of XML::Simple 🙂

    /I3az/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 401k
  • Answers 401k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When you say that "the normal git log shows you… May 15, 2026 at 4:32 am
  • Editorial Team
    Editorial Team added an answer $this->getUser() returns a myUser instance. You need $this->getUser()->getGuardUser(). May 15, 2026 at 4:32 am
  • Editorial Team
    Editorial Team added an answer public class A extends B{ @Override public void foo(){ System.out.println("yep");… May 15, 2026 at 4:32 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.