Perl script to extract 'ID' From XML File

File1.xml
<?xml version.........>

  • <abcd:abcd_list version="1" www.john_uncle's_server.com" xmlns:
  • <device id="100">
    <firmware>12.4(3d)</firmware>
    <location id="500">Sitting Room</location>
    </device>
  • <device id="101">
    <firmware>12.4(3d)</firmware>
    <location id="501">Class Room</location>
    </device>
    </abcd:abcd_list>

Perl Script Created as:

$list= $twig->root; 
@lists= $list->children; 
 
foreach $home ( @homes)
{ 
$e_location = $record->first_child( 'location'); 
$location = $e_record->text;
}

Question:
I could print any information under device, but how can i get device id's (100 and 101) itself.

Thanks.

You going to loop to print the child elements , you need to derefer the root element to print it.