Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML returned as hash problem

Status
Not open for further replies.

mhamilton3

Programmer
Oct 31, 2001
129
I am having a problem gathing the data from an XML stream. The code is as follows:
Code:
my $XMLref = $xs->XMLin($result, suppressempty => '');
using
Code:
use Data::Dumper;
print Dumper($XMLref);
I get the following HASH
Code:
$VAR = { 'wellmed' => { 'wellmedack' => {}, 'wellmed.ack' => { 'errors' => '0', 'wellmed.response' => 'User data updated for ID: aac20fd41e07ea11d9bfc1ac192a16aa77', 'responses' => '1' } } };

I can not get the result of either wellmed.response or errors. Here is what I tried - could someone please point out where I went wrong?

Code:
print $XMLref->{wellmed}->{wellmed.ack}->{errors}

Thanks.
 
Try putting a couple of quotes in there:
Code:
#!/usr/bin/perl

$VAR = { 'wellmed' => 
	{ 'wellmedack' => {},
	  'wellmed.ack' => { 'errors' => '0', 'wellmed.response' => 'User data updated for ID: aac20fd41e07ea11d9bfc1ac192a16aa77',
		  'responses' => '1' }
	}
       };
       
$response = $VAR->{wellmed}->{wellmed.ack}->{wellmed.response};
$response2 = $VAR->{'wellmed'}->{'wellmed.ack'}->{'wellmed.response'};
print "Response 1: $response\nResponse 2: $response2\n";
 
Thanks I found through my research that Perl does not like the "." in the middle of the tag. I went with the quotes and life is good again. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top