#!/usr/bin/perl use XML::Twig; my $Twig = new XML::Twig( pretty_print => 'indented'); eval { $Twig->parsefile("/root/IP.xml") }; print "Caught error: $@\n" if $@; my $root = $Twig->root; my $Red_Ifc; my $ether; $i = 0; foreach $ether ($root->children('Config')) { if($i == 1) { $ether->first_child('Ethernet')->set_text("eth10"); } $i++; } $root->print; $root->print_to_file("/root/one.xml");