Home > Archive > PERL Beginners > October 2005 > Troubles getting a value out of an XML object
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Troubles getting a value out of an XML object
|
|
| Dave Adams 2005-10-24, 6:56 pm |
| I am having troubles getting a value out of an XML object.
*Here is my object:*
my $xml = new XML::Simple;
my $data = $xml->XMLin($ResponseDoc);
*Here is the script asking for a snippet of data:*
print Dumper($data->{CreateLock});
**
*Here is the output:*
$VAR1 = { 'DatabaseId' => 'db1', 'RecordNumber' => '23617', 'Id' =>'test'
};
*Question:* How do I get the value of RecordNumber?
Thanks in advance.
Dave Adams
| |
| Jeff 'japhy' Pinyan 2005-10-24, 6:56 pm |
| On Oct 24, Dave Adams said:
> my $xml = new XML::Simple;
> my $data = $xml->XMLin($ResponseDoc);
> print Dumper($data->{CreateLock});
> $VAR1 = { 'DatabaseId' => 'db1', 'RecordNumber' => '23617', 'Id' => 'test'
> };
> *Question:* How do I get the value of RecordNumber?
You knew how to get 'CreateLock' from $data, but you don't know how to get
'RecordNumber' from $data->{CreateLock}?
my $rec = $data->{CreateLock}->{RecordNumber};
# or, without the extra ->
my $rec = $data->{CreateLock}{RecordNumber};
The object is merely a hash of hashrefs (of hashrefs, etc.).
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
|
|
|
|
|