Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: XML parsing

by trizen (Hermit)
on Jan 09, 2012 at 01:35 UTC ( #946933=note: print w/replies, xml ) Need Help??


in reply to XML parsing

Try this:
use 5.010; use XML::Simple; use Data::Dumper; my $ref = XMLin(join('', <DATA>)); print Dumper($ref); foreach my $i (0 .. $#{$ref->{'desc'}{'descript'}}) { say $ref->{'desc'}{'descript'}[$i]{'content'}; } __DATA__ <entry type="CVE" severity="Medium"> <desc> <descript source="cve">test1</descript> <descript source="nvd">test2</descript> </desc> </entry>

Replies are listed 'Best First'.
Re^2: XML parsing
by asa (Novice) on Jan 09, 2012 at 08:31 UTC

    Actually I was trying something like this

    foreach $desc ( @{ $e->{desc}->{descript} } ) { print REPORT $desc->{source}.':'; print REPORT $desc->{content}. '<br>'; }
    But I don't understand why it doesn't work! Not an ARRAY reference at ./parser.pl line 47. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946933]
help
Chatterbox?
[Your Mother]: Sure, sure. I had a cat as a kid who always slept on top of the fridge because of the heat dissipation up the back.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2017-12-18 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (492 votes). Check out past polls.

    Notices?