in reply to Re: Parse multiple xml tags with different names to an array
in thread Parse multiple xml tags with different names to an array
use XML::LibXML; use XML::Simple; my $xml_simple = new XML::Simple( SuppressEmpty => 1, KeyAttr => "INDEX", ForceArray => 1, KeepRoot => 1, ); my @nodeblocks; my $parser = XML::LibXML->new(); my $doc = $parser->parse_string($string); my @nodes = $doc->findnodes("//ROOT_TAG/*"); foreach my $node(@nodes) { my $str = $node->tostring(); my $str_hash = $xml_simple->XMLin($str); push(@nodeblocks, $str_hash); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parse multiple xml tags with different names to an array
by Anonymous Monk on Sep 26, 2013 at 13:19 UTC |