Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: XML parsing

by trizen (Friar)
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 drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-04-20 19:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (486 votes), past polls