Perl - Read XML
- by chinna_82
XML
<?xml version='1.0'?>
<employee>
<name>Smith</name>
<age>43</age>
<sex>M</sex>
<department role='manager'>Operations</department>
</employee>
Perl
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple;
foreach my $data1 ($data = $xml->XMLin("test.xml")) {
print Dumper($data1);
}
Above code managed to all the xml value like this.
Output
$VAR1 = {
'department' => {
'content' => 'Operations',
'role' => 'manager'
},
'name' => 'John Doe',
'sex' => 'M',
'age' => '43'
};
How do I do, if I only want to get the role value. For this example I need to get Role = manager. Any advice or reference link is highly appreciated.