Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 ./ line 47. Thanks.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946933]
[erix]: OT++: /me came across an osprey (=visarend (=Fischadler)) just now
[erix]: (osprey are pretty rare in NL)
[jkva]: erix whereabouts?
[erix]: Hey jkva! I am on Texel at the moment :)
[jkva]: Oh nice :)
[erix]: probably a 'doortrekker' ...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-10-20 10:11 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (260 votes). Check out past polls.