Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: problem in XML parsing

by ikegami (Patriarch)
on Mar 22, 2008 at 05:29 UTC ( [id://675589]=note: print w/replies, xml ) Need Help??


in reply to Re: problem in XML parsing
in thread problem in XML parsing

I don't like XML::Simple. Remove a team from the sample data and you get

Not an ARRAY reference at 675580.pl line 16.

Remove a player from ONE and you'll get

ONE Not an ARRAY reference at 675580.pl line 18.

The call to XMLin for this schema should be *at least*

my $teams = XMLin( $xml_text, ForceArray => [qw( football_team Player )], );

And then there's ForceContent.

XML::Simple is deceptively complex to use because it returns data in an unpredictable format, forcing you to use ref all over the place or to specify arguments to tell it what it already knows but chooses to destroy. All that because XML::Simple assumes attributes and elements are interchangeable. (Are they ever?)

Replies are listed 'Best First'.
Re^3: problem in XML parsing
by hipowls (Curate) on Mar 22, 2008 at 07:03 UTC

    Thanks for pointing out the potential problem with my code, I've updated the original post.

    I agree that XML::Simple isn't simple but at some point you have to provide a mapping between XML and perl data structures and nothing is truly simple. For reading XML without attributes it is good enough, though you do need to be aware of the traps (but that's what the man page and perlmonks are for;).

    For "real" XML processing I'd look elsewhere but this wasn't that question and then I'd be far more likely to seek advice than offer it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://675589]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2024-04-24 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found