title: Parse XML to store in a database
body: <p>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.</p>
  
  <p>Here is the current code:</p>
  
  <pre><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)
  </code></pre>
  
  <p>Here's the settings.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;settings&gt;
      &lt;category label="30101"&gt;
          &lt;setting id="source" label="30101" type="labelenum" default="YouSee.tv"
                   values="YouSee.tv|XMLTV|ONTV.dk" /&gt;
  
          &lt;setting id="youseetv.category" label="30102" type="labelenum" default="Danske"
                   values="Danske|Filmkanaler|Grundpakken|Mellempakken|Fuldpakken|Nordiske|Engelske|Tyske|L​atinske|Slaviske|Tyrkiske|Kurdiske|Arabiske|Asiatiske"
                   visible="eq(-1,0)" /&gt;
          &lt;setting id="program.background.enabled" label="30107" type="bool" default="true" visible="eq(-2,0)"/&gt;
          &lt;setting id="english.enabled" value="true"/&gt;
          &lt;setting id="french.enabled" value="false"/&gt;
          &lt;setting id="xmltv.file" label="30103" type="file" visible="eq(-3,1)" /&gt;
          &lt;setting id="xmltv.logo.folder" label="30116" type="folder" visible="eq(-4,1)"/&gt;
          &lt;setting id="ontv.url" label="30117" type="text" visible="eq(-5,2)" default="http://ontv.dk/xmltv/c81e728d9d4c2f636f067f89cc14862c"/&gt;
      &lt;/category&gt;
  &lt;/settings&gt;
  </code></pre>
  
  <p>I'm reading the xml data from this website: <a href="http://ontv.dk/xmltv/c81e728d9d4c2f636f067f89cc14862c" rel="nofollow">http://ontv.dk/xmltv/c81e728d9d4c2f636f067f89cc14862c</a></p>
  
  <p>I know how to read the xml data with <code>response.read()</code>, but I still have no idea how to parse the xml data to store in the database. </p>
  
  <p>How I can parse the xml data and store it in the database?</p>