For the below check1.xml
<root>
<setup name = "abc" version="1.1.1>
<func>
<comp name = "cba">
<check>type</check>
</comp>
</func>
</setup>
</root>
i am able to extract the field content of comp using the below
my $lib = "check1.xml";
my $simple = XML::Simple->new();
my $tree = $simple->XMLin($lib);
print $tree->{setup}->{func}->{comp}->{name} ;
With this, i am able to print "cba" .I printed the $tree with the Dumper function to get the hash and i was able to construct the syntax to print the same.
However when i have multiple comp tags, i am having issues.
<root>
<setup name = "abc" version="1.1.1">
<func>
<comp name = "cba">
<check>type</check>
</comp>
<comp name = "cdf">
<check>semi</check>
</comp>
<comp name = "mno">
<check>auto</check>
</comp>
<comp name = "xyz">
<check>manual</check>
</comp>
</func>
</setup>
</root>
How do i get the values here as when do i dump of the hash for this, i am not getting the same tag as i don't see any element i can access in the hash to get the info i need.
$VAR1 = {
'setup' => {
'func' => {
'comp' => {
'cdf' => {
'check' => 'semi'
},
'mno' => {
'check' => 'auto'
},
'cba' => {
'check' => 'type'
},
'xyz' => {
'check' => 'manual'
}
}
},
'name' => 'abc',
'version' => '1.1.1'
}
};
I would like to extract the comp name values from the above hash to an array. Can someone give me some pointers here. i.e. get cdf, mno,xyz, cba...