Try using Data::Dumper to examine the structure of $data. Then you might have better luck at figuring out how to access the various fields.
use Data::Dumper; print(Dumper($data));
You need
use strict ; use warnings ; use XML::Simple ; my $xml = <<'EOD' ; <database name="somedb"> <table name="table1"> <column name="column11" type="CHAR" /> <column name="column12" type="CHAR" /> </table> <table name="table2"> <column name="column21" type="CHAR" /> <column name="column22" type="CHAR" /> </table> </database> EOD my $data = XMLin( $xml, forcearray => 1 ) ; foreach my $table_name ( keys(%{$data->{'table'}}) ) { my $table = $data->{'table'}{$table_name}; foreach my $column_name ( keys(%{$table->{'column'}}) ) { my $column = $table->{'column'}{$column_name}; my $column_type = $column->{'type'}; print("Type of column $column_name in table $table_name is $colu +mn_type.\n"); } }
In reply to Re: Help!! XML::Simple with nested arrays
by ikegami
in thread Help!! XML::Simple with nested arrays
by Frank John
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |