If you're using XML::Simple and it's slow, the first thing to check is what parser you're using. If you have version 1.08_01 of XML::Simple and you have XML::SAX installed then you may using XML::SAX::PurePerl which is slow. Look for ParserDetails.ini in the site_lib/XML/SAX directory. All your installed SAX parsers are listed in this file and the last one listed will be used by default. If you don't already have XML::LibXML installed then that's the fastest XML parser available and XML::Simple will use it if you have SAX installed.
I'd also suggest a couple of tweaks to your code to squeeze a little more efficiency out of it. Both the <field> and <child> elements are being folded into hashes (on the 'name' and 'id' attributes respectively). You are then processing every element in each of these hashes by iterating over keys. A more efficient way would be to set the option keyattr => {} on the call to XMLin() to disable folding. Then you can iterate through the resulting arrays (rather than hashes) with:
foreach ( @{$node->{data}{field}} ) { $template->param( $_->{name} => $_->{content} ); }
For maximum efficiency, you'll want to ditch XML::Simple altogether and refactor your code into a SAX handler.
In reply to Re: Node Parser too slow?
by grantm
in thread Node Parser too slow?
by BioHazard
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |