in reply to XML::Simple find and add

KeyAttr should be 'id', (which is set by default anyway), you also need to set on ForceArray (a single 'tc' element would parse differently otherwise, have a look in the docs.)

The total code is then as simple as...

my $xml_string = qq| <exec> <tc id="001.001" version=""/> </exec>|; my $xml_simple = XMLin( $xml_string, 'ForceArray' => 1); $xml_simple->{'tc'}->{'001.001'}->{'version'} = "new value"; print XMLout($xml_simple);
---
my name's not Keith, and I'm not reasonable.