Perlbeginner1 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; my $xmlfile = shift || die "Usage: $0 <XML_FILE>\n"; my $ref; eval { $ref = XMLin($xmlfile, ForceArray => 0, KeyAttr => [ ], SuppressEmpty => '', ) or die "Can't read XML from $xmlfile: $!\n"; }; die $@ if($@); print Dumper $ref;
i runned this - and it looks nice.. Do you think that this is an appropiate way to do this?<?xml version="1.0" encoding="UTF-8"?> <osm version="0.6" generator="Overpass API"> <note>The data included in this document is from www.openstreetmap.org +. The data is made available under ODbL.</note> <meta osm_base=":49:02Z"/> <node id="297467" lat="49.5014" lon="8.1465"> <tag k="addr:city" v="Stuttgart"/> <tag k="addr:housenumber" v="23"/> <tag k="addr:postcode" v="69115"/> <tag k="addr:street" v="Sofienstraße"/> <tag k="name" v="ARLT"/> <tag k="phone" v="+49 6221 20229"/> <tag k="shop" v="computer"/> <tag k="source" v="survey"/> <tag k="website" v="http://www.arlt.com"/> <tag k="wheelchair" v="yes"/> </node> <node id="305144906" lat="49.40012" lon="8.6929652"> <tag k="addr:city" v="Mainz"/> <tag k="addr:country" v="DE"/> <tag k="addr:housenumber" v="13-15"/> <tag k="addr:postcode" v="69115"/> <tag k="addr:state" v="Baden-Württemberg"/> <tag k="addr:street" v="Rohrbacher Straße"/> <tag k="name" v="Heidel-bike"/> <tag k="opening_hours" v="Tu-Fr 10:00-18:30; Sa 10:00-14:00"/> <tag k="shop" v="bicycle"/> <tag k="website" v="http://www.heidelbike.de/"/> <tag k="wheelchair" v="yes"/> </node>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Simple to parse a xml-file and transform it to csv
by choroba (Cardinal) on Apr 29, 2014 at 17:14 UTC | |
by Perlbeginner1 (Scribe) on Apr 29, 2014 at 18:05 UTC | |
by choroba (Cardinal) on Apr 29, 2014 at 20:02 UTC | |
|
Re: XML::Simple to parse a xml-file and transform it to csv
by Discipulus (Canon) on Apr 30, 2014 at 07:56 UTC | |
by Perlbeginner1 (Scribe) on May 14, 2014 at 18:36 UTC |