Hi Monks!
I am trying to parse this data, wich is the result of this code
my $xml = XMLin($rss); using XML::SIMPLE
I am lost here, trying to use this, but how to get to this value city->name. If I can get the name in city I can figure it out how to get to the others I also need. With the foreach I can only get to the keys:
foreach my $vals ( keys %{ $xml }){
print Dumper $vals;
}
Test Data:
$VAR1 = {
'precipitation' => {
'mode' => 'no'
},
'pressure' => {
'unit' => 'hPa',
'value' => '1031.65'
},
'temperature' => {
'min' => '81.15',
'value' => '81.15',
'max' => '81.15',
'unit' => 'fahrenheit'
},
'humidity' => {
'unit' => '%',
'value' => '89'
},
'visibility' => {},
'wind' => {
'direction' => {
'value' => '202.503',
'name' => 'South-southwest',
'code' => 'SSW'
},
'gusts' => {},
'speed' => {
'name' => 'Gentle Breeze',
'value' => '4.61'
}
},
'clouds' => {
'name' => 'clear sky',
'value' => '8'
},
'weather' => {
'value' => 'clear sky',
'icon' => '02d',
'number' => '800'
},
'lastupdate' => {
'value' => '2016-05-16T18:27:33'
},
'city' => {
'name' => 'Pine Island Center',
'id' => '4168493',
'coord' => {
'lat' => '26.61',
'lon' => '-82.12'
},
'sun' => {
'rise' => '2016-05-16T10:40:09',
'set' => '2016-05-17T00:09:55'
},
'country' => 'US'
}
};
Thank you for helping! using XML::SIMPLE
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.