Hi Monkees,
Actually, put a hold on this for the moment - setting forcearray to 1 seems to resolve my initial problem, but I may be back with further probs. RSN...
With the following code, I want $xml_src and $xml_out to be identical, but everything inside bar ends up as an attribute of bar. What am I doing wrong?
I'm fairly sure that it's to do with needing keyattr and forcearray, but I'm struggling to understand what I'm meant to do...
use strict; use XML::Simple; 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, ); my $xml_out = XMLout(Test(), rootname=>'foo'); # how do I make $xml_out == $xml_src ? 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; }
Can anyone advise?
In reply to XML::Simple help please by Melly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |