in reply to XPath crashing
Loading 32MB of XML into a DOM structure is bound to use quite a lot of memory, but it seems the XML::XPath->find() is buggy. In either case you'd be better of using something that doesn't build the whole structure, expecially if as you said in the other node you only need very little out of the large XML. XML::Twig or maybe XML::Rules ;-)
It's hard to give you an example without knowing the XML, but using XML::Rules you might start with:
And you end up with a data structure containing only the content of the <user> tags you are interested in. And at no time is the whole document in memory, the module only keeps the data you wanted and the attributes of the yet unclosed nodes in memory.my $parser = XML::Rules->new( rules => [ 'computers,and,other,tags,you do not care about at all' => 'skip', '^user' => sub {return $_[1]->{teamid} eq $CONFIG{teamid} }, 'user' => 'as array', # only the <user> tags containing the right attribute will be proce +ssed '_default' => 'as is', 'tags,with,no,attributes' => 'content', ] ); my $data = $parser->parse($the_xml);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XPath crashing
by adrianxw (Acolyte) on Feb 05, 2007 at 20:47 UTC | |
by Jenda (Abbot) on Feb 05, 2007 at 22:59 UTC |