Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks
I am parsing a big XML file (~500Mb) with the following script. I run out of memory even if I set the uption HUGE
#!/usr/bin/env perl use strict; use warnings; use XML::LibXML; print "Importing...\n"; my $file = 'my.xml'; my $dom = XML::LibXML->load_xml(location => $file, huge => 1,); foreach my $termEntry ($dom->findnodes('/martif/text/body/termEntry')) + { foreach my $lang_set ($termEntry->findnodes('langSet')) { my $language = $lang_set->getAttribute('xml:lang'); foreach my $term_grp ($lang_set->findnodes('./tig')){ my $term = $term_grp->findvalue('./term'); print "$language: $term\n"; } } } print "Done!\n"; exit;
The script works perfectly with smaller files. Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::LibXML out of memory
by choroba (Cardinal) on May 04, 2017 at 23:40 UTC | |
by Anonymous Monk on Mar 24, 2022 at 11:52 UTC | |
by choroba (Cardinal) on Mar 24, 2022 at 12:01 UTC | |
by Anonymous Monk on Mar 24, 2022 at 13:49 UTC | |
|
Re: XML::LibXML out of memory
by marto (Cardinal) on May 04, 2017 at 20:27 UTC | |
|
Re: XML::LibXML out of memory
by Discipulus (Canon) on May 04, 2017 at 20:49 UTC | |
|
Re: XML::LibXML out of memory
by Corion (Patriarch) on May 04, 2017 at 20:31 UTC | |
|
Re: XML::LibXML out of memory
by haukex (Archbishop) on May 05, 2017 at 07:21 UTC | |
|
Re: XML::LibXML out of memory
by Anonymous Monk on May 04, 2017 at 21:24 UTC | |
|
Re: XML::LibXML out of memory
by Anonymous Monk on May 05, 2017 at 03:21 UTC | |
by kevbot (Vicar) on May 05, 2017 at 05:38 UTC | |
by Anonymous Monk on May 05, 2017 at 14:45 UTC |