CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [dilbert] SimpleXMLElement::xpath - how to sort a osm-request output: Edit Log



Laurent_R
Veteran / Moderator

Sep 13, 2015, 2:10 AM


Views: 879
Re: [dilbert] SimpleXMLElement::xpath - how to sort a osm-request output

Your input does not look like XML, but more like JSON. Maybe you want to try a JSON module from CPAN, or possibly the JSON::PP module which has been a core module since Perl 5.14.

Otherwise, I am not very clear, from what you said, about what exactly you want to store into your database or your spreadsheet. In most cases, though, the first step would be to transform your input data into a, internal Perl data structure (probably a hash of hashes, or some variation thereof) in order to manipulate your data conveniently.

Your data might end up as a HoH similar to this:


Code
$VAR1 = { 
'lat' => '41.4138593',
'lon' => '2.1970778',
'id' => 618312181,
'type' => 'node',
'tags' => {
'health_facility:type' => 'health_centre',
'addr:housenumber' => '211',
'name' => 'CAP Sant MartÝ',
'addr:postcode' => '08020',
'phone' => '+93 307 07 66',
'medical_system:western' => 'yes',
'amenity' => 'hospital',
'addr:city' => 'Barcelona',
'addr:street' => 'Carrer de FluviÓ'
}
};

which is then quite easy to rework for inserting into a DB or a spreadsheet. (Or you might want to further process the addr:xxx tags into a further nested structure, it depends what you really need.)


(This post was edited by Laurent_R on Sep 13, 2015, 2:12 AM)


Edit Log:
Post edited by Laurent_R (Veteran) on Sep 13, 2015, 2:12 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives