views:

50

answers:

2

I'm trying to fetch data from a XML service... this one.

http://xmlweather.vedur.is/?op_w=xml&type=forec&lang=is&view=xml&ids=1

I'm using urrlib and minidom and i can't seem to make it work. I've used minidom with files and not url.

This is the code im trying to use

xmlurl = 'http://xmlweather.vedur.is'
xmlpath = xmlurl + '?op_w=xml&type=forec&lang=is&view=xml&ids=' + str(location)
xmldoc = minidom.parse(urllib.urlopen(xmlpath))

Can anyone help me?

A: 

Try this:

f = urllib.urlopen(xmlpath)
html = f.read()
xmldoc = minidom.parse(html)
Martin
+1  A: 

The following should work (or at least give you a strong idea about what is going wrong):

from xml.dom.minidom import parse
import urllib

xmlurl = 'http://xmlweather.vedur.is'
xmlpath = xmlurl + '?op_w=xml&type=forec&lang=is&view=xml&ids=' + str(location)
try:
    xml = urllib.urlopen(xmlpath)
    dom = parse(xml)
except e as Exception:
    print(e)
Ashish
Works for my app hosted on Google Apps.
Ashish