I'm working on a Python script to read xml data from a web server. I also want to store the data in an sqlite database, but I still have no idea how to parse the xml data prior to storing the data.
Here is the current code:
import xbmc
import xbmcgui
import xbmcaddon
import urllib2
ADDON = xbmcaddon.Addon(id = 'script.myaddon')
class MyScript(xbmcgui.WindowXML):
def __new__(cls):
return super(MyScript, cls).__new__(cls, 'script-menu.xml', ADDON.getAddonInfo('path'))
def onInit(self):
url = ADDON.getSetting('ontv.url')
req = urllib2.Request(url)
response = urllib2.urlopen(req)
data = response.read()
response.close()
profilePath = xbmc.translatePath(os.path.join('special://userdata/addon_data/script.tvguide', ''))
if os.path.exists(profilePath):
profilePath = profilePath + 'source.db'
con = lite.connect(profilePath)
cur = con.cursor()
cur.execute('CREATE TABLE IF NOT EXISTS data (channels, programme_title, programme_time, description, logo_url)')
cur.close()
return data
cSetVisible(self,4201,True)