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

Re^2: data extraction XML::Simple

by jonnyfolk (Vicar)
on Mar 10, 2010 at 23:07 UTC ( #827915=note: print w/ replies, xml ) Need Help??


in reply to Re: data extraction XML::Simple
in thread data extraction XML::Simple

Hi hadn't realized that the root node was removed, and you example works, thank you very much. Making string more complex, and trying to take you advice into account I am still drawing a blank!!

$newxml = qq~ <record> <namepairs> <name>My Name </name> <img>My image</img> <brochure>My Brochure</brochure> </namepairs> </record>~; my $xml = new XML::Simple(ForceArray => 1, KeyAttr => [], KeepRoot => +1, SuppressEmpty => ''); my $data = $xml->XMLin(\$newxml); #print $data->{'name'}; print $data->{'namepairs'}->{'name'}; #print Dumper($data); exit;


Comment on Re^2: data extraction XML::Simple
Download Code
Re^3: data extraction XML::Simple
by ikegami (Pope) on Mar 10, 2010 at 23:12 UTC
    The dump shows
    VAR1 = { 'record' => [ { 'namepairs' => [ { 'brochure' => [ 'My Brochure' ], 'name' => [ 'My Name ' ], 'img' => [ 'My image' ] } ] } ] };

    You don't account for the top level hash or any of the arrays.

    print $data->{record}[0]{namepairs}[0]{name}[0];
      Ok, I hadn't understood the difference between the two structures I had posted. It's much clearer to me now. Thanks very much for you help and time.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2015-07-02 03:56 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 (27 votes), past polls