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>

Comment on Re: XML parsing
Download Code
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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2015-11-29 17:28 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (751 votes), past polls