my $XML = XML::Smart->new() ; $XML->{Shelf_Info} ; $XML->{Shelf_Info}{switch}{Name} = "$pp"; $XML->{Shelf_Info}{switch}{shelfType} = '15000'; $XML->{Shelf_Info}{switch}{shelfType}->set_node(1); $XML->{Shelf_Info}{switch}{commentText} = "$comment"; $XML->{Shelf_Info}{switch}{commentText}->set_node(2); $XML->save('test.xml') ;