Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

XML::Simple Help?
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???

-----------------------------------
Test Code (response is copied from actual data):

#!/usr/bin/perl

use XML::Simple;
use Data::Dumper;
$content="<response>
<result>12</result>
<respmsg>Decline</respmsg>
<authcode>RE-PRESENTED CHK</authcode>
<pnref>99220</pnref>
</response>";
$tags = XMLin($content);
print "\n\nDumper:\n";
print Dumper($tags);

-----------------------------------
Results:


Dumper:
$VAR1 = {
'authcode' => 'LREADY USED',
'pnref' => '99220',
'respmsg' => 'Denied',
'result' => '12'
};
-----------------------------------

So... $tags contains what I'm looking for... now I need to be able to
use the four items!

Anyone?


Report this thread to moderator Post Follow-up to this message
Old Post
Vin Grover
04-24-05 01:55 AM


Re: XML::Simple Help?
Vin Grover <grover037@hottttmail.com> wrote on Sat, 23 Apr 2005
16:09:29 -0500:

As usually happens, after giving up and begging for help, I promptly
found the answer...

$content->{result} etc...


duhhhh...


>
>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???
>
>-----------------------------------
>Test Code (response is copied from actual data):
>
>#!/usr/bin/perl
>
>use XML::Simple;
>use Data::Dumper;
>$content="<response>
>  <result>12</result>
>  <respmsg>Decline</respmsg>
>  <authcode>RE-PRESENTED CHK</authcode>
>  <pnref>99220</pnref>
>  </response>";
>$tags = XMLin($content);
>print "\n\nDumper:\n";
>print Dumper($tags);
>
>-----------------------------------
>        Results:
>
>
>Dumper:
>$VAR1 = {
>          'authcode' => 'LREADY USED',
>          'pnref' => '99220',
>          'respmsg' => 'Denied',
>          'result' => '12'
>        };
>-----------------------------------
>
>So... $tags contains what I'm looking for... now I need to be able to
>use the four items!
>
>Anyone?


Report this thread to moderator Post Follow-up to this message
Old Post
Vin Grover
04-24-05 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:23 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.