diomedea has asked for the wisdom of the Perl Monks concerning the following question:
@xmlfiles = qw(file1.xml file2.xml); foreach my $xfile (@xmlfiles) { $twig = new XML::Twig( twig_roots => { 'pdb_entry/pdb_code' => \&pdb_entry, 'pdb_entry/total_asm' => \&pdb_entry, 'pdb_entry/asm_set/assembly' => \&assembly,}); &parse_twig($xfile); } sub parse_twig { my $file = shift; if ($twig->safe_parsefile($file) == 0) { die "Failed to parse $file: $@"; } my $root = $twig->root; my @params = $root->children('pdb_entry'); $twig->purge; $twig->dispose; } ... handler code here
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: parsing multiple xml files with xml::twig
by citromatik (Curate) on Jun 07, 2007 at 16:19 UTC | |
by diomedea (Sexton) on Jun 08, 2007 at 09:54 UTC | |
by diomedea (Sexton) on Jun 08, 2007 at 13:36 UTC |