OK, I am writing a program to grab an XML parse, possibly update). So I am using XML::Simple. My question is how can I, in a generic form reliably access the data if it is a hash or data or arrays ?
I have tried (and other permutations): scalar @$ref->{$_} (exists $ref->{$_}[0]) (defined $ref->{$_}[0]) Some just return the data, ones with [0] break when it is on a node that just returns the data. Tips/Pointers/RTFMs appreciated Andymy $file1=shift; use XML::Simple; use Data::Dumper; my $xml; open (IN, "<$file1") || die "[r] '$file1' ($!)"; { local $/ = undef; $xml=<IN>; } close(IN); my $ref = XMLin($xml); foreach (keys %{$ref}) { print $_." ".$ref->{$_}." "."\n"; }
In reply to Parsing generic XML by aknipp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |