Discussion:
[Community] Parsing xml capabilities file in owslib
Nick Gart
2012-03-25 20:46:27 UTC
Permalink
(originally sent to owslib-users but that list seems to not be active)


I am trying to create a WebMapService from this url:
http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED_3/capabilities_1_3_0.xml

but it doesn't seem to be parsing correctly:


?File "<stdin>", line 1, in <module>
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 86, in __init__
? ?self._buildMetadata(parse_remote_metadata)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 101, in _buildMetadata
? ?self.identification=ServiceIdentification(serviceelem, self.version)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 267, in __init__
? ?self.type = testXMLValue(self._root.find('Name'))
AttributeError: 'NoneType' object has no attribute 'find'


Since the URl isn't a CGI link, I tried pulling the XML and feeding
capurl = urllib2.urlopen('http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED_3/capabilities_1_3_0.xml').readlines()
capstring = "".join(capurl)
wms = WebMapService('',xml=capstring)
Traceback (most recent call last):
?File "<stdin>", line 1, in <module>
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 86, in __init__
? ?self._buildMetadata(parse_remote_metadata)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 101, in _buildMetadata
? ?self.identification=ServiceIdentification(serviceelem, self.version)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 267, in __init__
? ?self.type = testXMLValue(self._root.find('Name'))
AttributeError: 'NoneType' object has no attribute 'find'


Am I going about this properly?
Thanks
Nick Gart
2012-03-25 20:48:42 UTC
Permalink
forgot to include the command that generated the first set of output:

wms = WebMapService('http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED_3/capabilities_1_3_0.xml')
Post by Nick Gart
(originally sent to owslib-users but that list seems to not be active)
http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED_3/capabilities_1_3_0.xml
?File "<stdin>", line 1, in <module>
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 86, in __init__
? ?self._buildMetadata(parse_remote_metadata)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 101, in _buildMetadata
? ?self.identification=ServiceIdentification(serviceelem, self.version)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 267, in __init__
? ?self.type = testXMLValue(self._root.find('Name'))
AttributeError: 'NoneType' object has no attribute 'find'
Since the URl isn't a CGI link, I tried pulling the XML and feeding
capurl = urllib2.urlopen('http://imselev.cr.usgs.gov/WMS_Capabilities/USGS_EDC_Elev_NED_3/capabilities_1_3_0.xml').readlines()
capstring = "".join(capurl)
wms = WebMapService('',xml=capstring)
?File "<stdin>", line 1, in <module>
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 86, in __init__
? ?self._buildMetadata(parse_remote_metadata)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 101, in _buildMetadata
? ?self.identification=ServiceIdentification(serviceelem, self.version)
?File "/Library/Python/2.5/site-packages/OWSLib-0.4.0-py2.5.egg/owslib/wms.py",
line 267, in __init__
? ?self.type = testXMLValue(self._root.find('Name'))
AttributeError: 'NoneType' object has no attribute 'find'
Am I going about this properly?
Thanks
Loading...