[GRASS-SVN] r46817 - grass-addons/grass7/gui/wxpython/wx.wms
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jun 28 04:46:14 EDT 2011
Author: sudeepsingh
Date: 2011-06-28 01:46:14 -0700 (Tue, 28 Jun 2011)
New Revision: 46817
Added:
grass-addons/grass7/gui/wxpython/wx.wms/parse.py
Log:
Code for parsing the xml response of the GetCapabilites, current version supports only command line interface, run as python parse.py
Added: grass-addons/grass7/gui/wxpython/wx.wms/parse.py
===================================================================
--- grass-addons/grass7/gui/wxpython/wx.wms/parse.py (rev 0)
+++ grass-addons/grass7/gui/wxpython/wx.wms/parse.py 2011-06-28 08:46:14 UTC (rev 46817)
@@ -0,0 +1,45 @@
+from xml.dom.minidom import parse, parseString
+from urllib2 import Request, urlopen, URLError, HTTPError
+
+def parsexml():
+ url = 'http://www.gisnet.lv/cgi-bin/topo?request=GetCapabilities&service=wms'
+ req = Request(url)
+ response = urlopen(req)
+ xml = response.read()
+ dom = parseString(xml)
+ layerlist = dom.getElementsByTagName('Layer')
+ for node in layerlist:
+ #print node.toxml()
+ namelist = node.getElementsByTagName('Name')
+ for name in namelist:
+ print name.toxml()
+ '''temp = node.getElementsByTagName('Name')
+ if hasattr(temp,'toxml'):
+ temp.toxml()
+ print 'yoyo'
+ else:
+ print 'dkndskjfnskdjnksdjfn'
+ '''
+
+
+ #print layerlist
+ '''forecasts = []
+ for node in dom.getElementsByTagNameNS(WEATHER_NS, 'forecast'):
+ forecasts.append({
+ 'date': node.getAttribute('date'),
+ 'low': node.getAttribute('low'),
+ 'high': node.getAttribute('high'),
+ 'condition': node.getAttribute('text')
+ })
+ ycondition = dom.getElementsByTagNameNS(WEATHER_NS, 'condition')[0]
+ return {
+ 'current_condition': ycondition.getAttribute('text'),
+ 'current_temp': ycondition.getAttribute('temp'),
+ 'forecasts': forecasts,
+ 'title': dom.getElementsByTagName('title')[0].firstChild.data
+ }'''
+
+
+
+parsexml()
+
More information about the grass-commit
mailing list