Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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>


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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-04 23:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls