I was fortunate enough yesterday to have the author of XML::Twig answer my question, and Mirod was very helpful, but unfortunately I still have one question remaing that I can't seem to find the answer to in the perldoc or elsewhere. I'm using the following code
This is my pseudo XML file:#!/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;
How can I navigate to a specific child of root, i.e. child or children?<root> <child> <children>foo_bar</children> </child> </root>
Thanks again for all the help
In reply to XML Twig children by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |