Iterating over nodes using XML::LibXML

前端 未结 1 575
渐次进展
渐次进展 2021-01-14 03:54

I am using XML::LibXML (Ver: 1.70).

My xml input file looks like this:




        
1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-14 04:39

    There's only one Equipments node, hence you only get one $camelid to scan. To remedy, you might change things slightly, say, to iterate over Equipment/ECIDs:

    foreach my $camelid ( $root->findnodes('Equipments/ECID') ) {
        my $name =  $camelid->findvalue('@logicalName');
        my $id =  $camelid->findvalue('@id');
        ...
    }
    

    0 讨论(0)
提交回复
热议问题