#!/perl/bin/perl -w use strict; use XML::Twig; my $twig= new XML::Twig; open( XML_OUT, ">output.xml") or die $!; $twig->parsefile( "RoamAboutAP_172.108.251.49.xml"); my $root= $twig->root; my $children= $twig->children; my @ds= $root->children('ds'); my @rra= $children-> # Not sure of the syntax for children of children; foreach my $attr (@ds) { my $test= "TESTING PLACEMENT FOR DS"; my $eblg= new XML::Twig::Elt( 'Average', $test); $eblg->paste( 'first_child', $attr); } foreach my $attr (@rra) { my $test= "TESTING PLACEMENT FOR RRA"; my $eblg= new XML::Twig::Elt( 'Average', $test); $eblg->paste( 'first_child', $attr); } # $twig->set_pretty_print('indented'); $twig->print( \*XML_OUT); close XML_OUT;