in reply to Remove level of elements (preserving their children) in XML::Twig?

Now the Simple way :)

#! perl -slw use strict; use XML::Simple; my $xml = XMLin( \*DATA, KeepRoot => 1 ); $xml->{policy}{Rule} = $xml->{policy}{policyrules}{Rule}; delete $xml->{policy}{policyrules}; print XMLout( $xml, KeepRoot => 1 ); __END__ <?xml version="1.0" encoding="UTF-8"?> <policy name="Cur_policy" version="3.2.1"> <policyrules> <Rule Action="allow" Enabled="true" RuleID="F68E32"> <source addr="10.4.5.3" srcport="any"/> <dest addr="199.5.4.3" destport="80"/> </Rule> <Rule Action="allow" Enabled="true" RuleID="78E21D"> <source addr="10.4.0.0-10.4.255.255" srcport="any"/> <dest addr="any" destport="80"/> </Rule> </policyrules> </policy>

Produces:

C:\test>xmljunk.pl <policy name="Cur_policy" version="3.2.1"> <Rule Action="allow" Enabled="true" RuleID="F68E32"> <dest addr="199.5.4.3" destport="80" /> <source addr="10.4.5.3" srcport="any" /> </Rule> <Rule Action="allow" Enabled="true" RuleID="78E21D"> <dest addr="any" destport="80" /> <source addr="10.4.0.0-10.4.255.255" srcport="any" /> </Rule> </policy>

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?