I'm new to perl. I'm parsing an XML string and need to print out its context. I'm having a really tough time with the correct syntax to use to access the array/hash it creates.
Data dumper prints out this...
$VAR1 = [
'ResultSet',
[
{
'xmlns' => 'urn:yahoo:maps',
'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation' => 'urn:yahoo:maps http://api.local.yahoo.com
/MapsService/V1/GeocodeResponse.xsd'
},
'Result',
[
{
'precision' => 'address'
},
'Latitude',
{},
0,
'28.312216'
,
'Longitude',
{},
0,
'-81.380514'
,
'Address',
{},
0,
'2335 Pepper Tree Ct'
,
'City',
{},
0,
'Kissimmee'
,
'State',
{},
0,
'FL'
,
'Zip',
{},
0,
'34744-2820'
,
'Country',
{},
0,
'US'
]
]
];
How do I access the latitude and longitude?
I tried this...
$data = $xml->parse($thedata);
print $data->{ResultSet}->{Result}->{Latitude};
But no luck. Any help would be greatly appreciated. Sorry the formatting was slightly destroyed. Also, I have to use XML::Parser, was using XML::Simple but encountered problems.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.