Posted to tcl by aspect at Tue Jan 02 22:45:30 GMT 2018view raw
- package require http
- package require tdom
- set ::http::defaultCharset utf-8
- set url {http://overpass-api.de/api/interpreter?data=%28way%2855.74%2C37.68%2C55.75%2C37.69%29%5B%22building%22%5D%5B%22addr%3Ahousenumber%22%5D%5B%22addr%3Astreet%22%5D%3Brelation%2855.74%2C37.68%2C55.75%2C37.69%29%5B%22building%22%5D%5B%22addr%3Ahousenumber%22%5D%5B%22addr%3Astreet%22%5D%3B%29%3Bout%3Bforeach%28%3E%3Bout%3B%29%3B}
- #set token [http::geturl $url -binary true]
- #set data [encoding convertfrom utf-8 [http::data $token]]
- set token [http::geturl $url]
- set data [http::data $token]
- http::cleanup $token
- set doc [dom parse $data]
- set root [$doc documentElement]
- puts [$root nodeName]
- foreach way [$root getElementsByTagName way] {
- foreach tag [$way getElementsByTagName tag] {
- set key [$tag getAttribute k]
- set value [$tag getAttribute v]
- puts "$key=$value"
- }
- puts "----------------------------------------"
- }
- $doc delete