my $xml_src = '<foo> <bar><number>1</number><foobar>Hello world</foobar><barfoo>Goodbye w +orld</barfoo></bar> <bar><number>2</number><foobar>abc</foobar><barfoo>def</barfoo></bar +> </foo>' ; my $xml_in = XMLin($xml_src, ForceArray => 1); my $xml_out = XMLout(Test(), rootname=>'foo'); print "Source:\n" . $xml_src . "\n\n"; print "Output:\n" . $xml_out . "\n"; sub Test{ my $entry; my $out; foreach $entry(@{${$xml_in}{'bar'}}){ push @{${$out}{'bar'}}, {%$entry} } return $out; } __output__ Source: <foo> <bar><number>1</number><foobar>Hello world</foobar><barfoo>Goodbye w +orld</barfoo></bar> <bar><number>2</number><foobar>abc</foobar><barfoo>def</barfoo></bar +> </foo> Output: <foo> <bar> <number>1</number> <barfoo>Goodbye world</barfoo> <foobar>Hello world</foobar> </bar> <bar> <number>2</number> <barfoo>def</barfoo> <foobar>abc</foobar> </bar> </foo>
_________
broquaint
In reply to Re: XML::Simple help please
by broquaint
in thread XML::Simple help please
by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |