#!/usr/bin/perl use strict; use warnings; use XML::Simple; my $in_file = "in.xml"; my $xml_file = 'out.xml'; my $xml = XMLin( $in_file, KeepRoot => 1, ForceArray => 1, ); # added ->{content}, so now attributes are preserved and stay $xml->{importrecord}->[0]->{aktionen}->[0]->{transaktion}->[0]->{aktion}->[0]->{parameter}->[0]->{attribut}->[0]->{content} = 'Anlegen'; XMLout( $xml, KeepRoot => 1, NoAttr => 0, OutputFile => $xml_file, );