|
Posted by Jim Gibson on July 1, 2005, 9:34 am
Please log in for more thread options
> I'm looking for a simple way to process results returned from a
> website via XML. I was thinking XML::Simple should be simple... but
> apparently I'm even simpler than it is!
>
>
> I'm having trouble figuring out how to get at the four items it
> returns. Looks like $tags contains a hash which is actually a data
> structure named $VAR1, which appears to define a hash, but how do I
> make it work? It looked empty, but Dumper shows the contents and they
> look like exactly what I want... but how do I access it???
>
>
>
You should have here:
use strict;
use warnings;
> use XML::Simple;
> use Data::Dumper;
> $content="<response>
Change the above line to:
my $content ...
> <result>12</result>
> <respmsg>Decline</respmsg>
>
> <authcode>RE-PRESENTED CHK</authcode>
> <pnref>99220</pnref>
> </response>";
> $tags = XMLin($content);
Ditto:
my $tags = ...
> print "\n\nDumper:\n";
> print Dumper($tags);
>
>
>
> RESULT
> ______________________________ Results:
>
>
> Dumper:
> $VAR1 = {
> 'authcode' => 'LREADY USED',
> 'pnref' => '99220',
> 'respmsg' => 'Denied',
> 'result' => '12'___
> 'result' => '12'
> };
This is not what I get when I run your program. You have changed the
authcode from 'LREADY USED' to 'RE-PRESENTED CHK', and I do not get two
'result' entries. Please post exact code and output from your program
so you don't confuse those trying to help you.
The $VAR1 is a name picked by the Data::Dumper module. This is
explained in the documentation for Data::Dumper, although perhaps not
so clearly as it could be. Have you read the documentation for
Data::Dumper? If you want a more explicit output format, you can use
the following:
print Data::Dumper->Dump([$tags], [qw(tags)]);
as explained in the documentation for Data::Dumper.
XMLin returns a reference to a hash. There are examples of how to
access the data in the documentation for XML::Simple. Have you read the
documentation for XML::Simple?
As an example in your case, the authcode entry is $.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000
Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
|