Re: XML to inMemory Hash
- From: prabu.ayyappan@xxxxxxxxx (Prabu Ayyappan)
- Date: Sat, 4 Aug 2007 10:50:44 -0700 (PDT)
Hi,
Yes its saving the memory.
But now am into a new problem :(
Its taking lot of time to parse a file.
Is there any way to create chunks so that it wont parse the entire file.
my requirement is to read the chunks based on an attribute.
I tried
my $twig = XML::Twig->new(twig_roots => {'node[@id="'.$ID.'"]' => \&chunks});
$twig->parse($showtimeString);
sub chunks{
my( $twig, $reOrganize)= @_;
$chunkedIXMLG = $_->sprint;
$twig->purge;
}
sub myprocess
{
print $chunkedIXMLG;
}
Also
my $twig = XML::Twig->new(twig_handlers => {'node[@id="'.$ID.'"]' => \&chunks});
$twig->parse($showtimeString);
sub chunks{
my( $twig, $reOrganize)= @_;
$chunkedIXMLG = $_->sprint;
$twig->purge;
}
Since it is reading the whole file each time to parse the node based on the ID.It is taking lot of time.I need to read a 100MB file each time to take the node.
Thanks in advance,
Prabu
Jenda Krynicky <Jenda@xxxxxxxxxxx> wrote:
From: Prabu Ayyappan
Thanks for the valuable inputs,
I am planning to solve my memory issue by making the XML into Chunks
using Xml::Twig and using simplify( ) in XML::Twig to convert that
chunks back into the Hash data structure.
Is that advicable method to proceed to reduce my Memory size.So that
after processing that chunk i will purge my memory (purge in
XML::Twig)
Thanks in advance,
Prabu
Yes, this should reduce the memory footprint while keeping the
necessary changes to the script small. I think in your case it's the
best solution.
Jenda
===== Jenda@xxxxxxxxxxx === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
---------------------------------
Ready for the edge of your seat? Check out tonight's top picks on Yahoo! TV.
- References:
- Re: XML to inMemory Hash
- From: Jenda Krynicky
- Re: XML to inMemory Hash
- Prev by Date: Re: XML to inMemory Hash
- Next by Date: print 2 valuable
- Previous by thread: Re: XML to inMemory Hash
- Next by thread: Re: parsing a log file by date
- Index(es):
Relevant Pages
|