Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: XML::Simple - Handling inconsistency

by vinoth.ree (Prior)
on Jan 09, 2013 at 07:56 UTC ( #1012404=note: print w/ replies, xml ) Need Help??


in reply to XML::Simple - Handling inconsistency

Is it helpful for you ?

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use XML::Simple; my $res = "<results> <binding name=\'image_url\'> <uri>Football.png</uri> </binding> <binding name=\'description\'> <literal xml:lang=\'en\'>First article. </literal> </binding> </results>"; my $res2 = "<results> <binding name=\'description\'> <literal xml:lang=\'en\'>Second article.</literal> </binding> </results>"; my $xml_simple = XML::Simple->new( KeepRoot => 1, KeyAttr => 1, ForceA +rray => 1 ); my $result = $xml_simple->XMLin($res); my $result2 = $xml_simple->XMLin($res2); print Dumper $result; print Dumper $result2;
Update:

Adding the output,

$VAR1 = { 'results' => [ { 'binding' => [ { 'name' => 'image_url', 'uri' => [ 'Football.png' ] }, { 'literal' => [ { 'content' => 'F +irst article. ', 'xml:lang' => ' +en' } ], 'name' => 'description' } ] } ] }; $VAR1 = { 'results' => [ { 'binding' => [ { 'literal' => [ { 'content' => 'S +econd article.', 'xml:lang' => ' +en' } ], 'name' => 'description' } ] } ] };


Comment on Re: XML::Simple - Handling inconsistency
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2015-07-05 10:47 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 (61 votes), past polls