in reply to Yet another XML::Simple question!

Your syntax for calling XMLout is wrong. It's just print XMLout($xml);.

The reason it's printing wrong is that your structure is wrong. You have:

'phonenumbers' => [ # <- Repeats phonennumbers { 'phonenumber' => { 'number' => '9163723752' } }, { 'phonenumber' => { 'number' => '9166413900' } } ]

You need:

'phonenumbers' => [ # <- Repeats phonennumbers { 'phonenumber' => [ # <- Repeats phonennumber { 'number' => '9163723752' }, { 'number' => '9166413900' } ] } ]

For example:

>type !.xml <campaign action="0" menuid="10118"> <phonenumbers> <phonenumber number="9163723752" /> <phonenumber number="9166413900" /> </phonenumbers> </campaign> >type !.pl use XML::Simple qw( XMLin XMLout ); # It didn't think "!.xml" was a file name until I added "./". # Options were lowercase in older versions (like the one I have. my $xml = XMLin('./!.xml', keeproot => 1, forcearray => 1); print XMLout($xml, keeproot => 1); >perl !.pl <campaign menuid="10118" action="0"> <phonenumbers> <phonenumber number="9163723752" /> <phonenumber number="9166413900" /> </phonenumbers> </campaign>

Update: Sorry, I was familiar with the OO calling syntax. My initial paragraph was wrong, but the rest still applies.

Replies are listed 'Best First'.
Re^2: Yet another XML::Simple question!
by jdtoronto (Prior) on Jul 19, 2005 at 20:05 UTC
    ikegami

    Well that makes sense! And it works too.

    When I am finished this job I will take the time to sit down and read something on the subject, this has beena harrowing experience and I have to say that the documentation I have found is obtuse to say the least.

    Thank you for your assistance

    jdtoronto

      Yeah, like what's the point of all that morphing?