On Sun, Nov 29, 2009 at 11:41 AM, Lennard <[email protected]> wrote:
> Maarten Deen wrote:
>
>> I've tried a few things, but I'm not fluent in perl. My problem at the 
>> moment is
>> that splitting a line on the space character seems logical, but you run into
>> problems if a value has a space in it.
>> So splitting something like <tag k="name" v="foo bar"/> will split the value
>> "foo bar" also.
>
> You have to be fluent in regexes, not perl as such. The trick is to
> match the quote, then to match anything that is not a quote, followed by
> a quote.


And then hope that the attributes are in the order you're expecting,
and that the XML has used " rather than '. And in the example code
given below hope that only one space was used.

If you know the OSM XML source that's probably not such a massive issue.
Don't forget to unescape any XML entities in the key or value as well.

The real trick of course is to use an XML parser which handles all of
this for you.

Dave

_______________________________________________
dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/dev

Reply via email to