Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Dereferencing a hashref from XML::Simple

by reneeb (Chaplain)
on Jul 28, 2006 at 10:54 UTC ( #564319=note: print w/ replies, xml ) Need Help??


in reply to Dereferencing a hashref from XML::Simple

Maybe this could help:

#!/usr/bin/perl use warnings; use strict; ; use XML::Simple qw(:strict); use Data::Dumper; my $xml =q(<?xml version="1.0"?> <response> <files> <file file_url="http://server.domain/file1.exe"> file1.exe </file> <file file_url="http://server.domain/file2.zip"> file2.zip </file> </files> </response> ); my $ref = XMLin($xml, forcearray => [ qw(files) ], keyattr => [] ); my %files; for my $elem(@{$ref->{files}}){ my $filesref = $elem->{file}; $files{$_->{content}} = $_->{file_url} for(@$filesref); } print Dumper(\%files);


Comment on Re: Dereferencing a hashref from XML::Simple
Download Code
Re^2: Dereferencing a hashref from XML::Simple
by helgi (Hermit) on Jul 28, 2006 at 10:59 UTC
    Thanks reneeb,

    but when I try to run that, I get:

    not well-formed (invalid token) at line 2, column 49, byte 93 at c:/Pe +rl/site/lib/XML/Parser.pm line 185
    Any ideas?


    --
    Regards,
    Helgi Briem
    hbriem AT f-prot DOT com

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://564319]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2015-07-03 15:53 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 (53 votes), past polls