Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Parsing generic XML

by wind (Priest)
on Jun 24, 2011 at 16:31 UTC ( #911274=note: print w/replies, xml ) Need Help??


in reply to Parsing generic XML

If you're asking how to access the data structure returned by XML::Simple, that entirely depends on the structure of your XML. There is nothing wrong with the code that you've listed above, but if you're wanting to know why $ref->{$_} isn't listing deeper contents, maybe it's because it's a more complex data structure than just a scalar?

If so, just use Data::Dumper to output it or use ref to determine what type it is and use recursion:

foreach (keys %{$ref}) { print $_." ".Dumper($ref->{$_})."\n"; }

Note, there are parameters that you can pass to XMLin to adjust the way that it creates the data structure from the source XML. Just read the cpan docs for more details.

Replies are listed 'Best First'.
Re^2: Parsing generic XML
by aknipp (Initiate) on Jun 24, 2011 at 16:50 UTC

    Thanks. I will try your code. The XML I plan to use is variable, so I was trying to write something rather generic. If I can identify a structure vs a node I should be OK.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://911274]
help
Chatterbox?
[LanX]: no idea ... ask py monks! ;-p
[tye]: it turns out that this can be caused by almost anything going wrong. If you want to know what caused the problem, you have to try to load each app by-hand to see what problems it is having, because none of those will be logged.
[tye]: No, I write more Perl than py at work. But I have to deal with plenty of py things.
[tye]: py monks would just be offended.
[Corion]: ;)
[Corion]: Hi tye btw ;)
[Corion]: I found plenty of not chatty enough logs with Perl too ... I'm slowly coming to appreciate Log::Log4perl resp. our homegrown alternative
[tye]: my experience with python so far is more like finding a moderately useful error message is a shocking surprise.
Corion disappears

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-09-21 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (252 votes). Check out past polls.

    Notices?