Parse XML in Python with lxml.etree
Question: How can I parse this site (<http://www.tvspielfilm.de/tv-
programm/rss/heute2015.xml>) with python to get for example the tv programm
for today on SAT at 20:15? I've tried the Python library lxml.etree, but I
failed:

    
    
    #!/usr/bin/python
    import lxml.etree as ET 
    import urllib2
    
    response = urllib2.urlopen('http://www.tvspielfilm.de/tv-programm/rss/heute2015.xml')
    xml = response.read()
    
    root = ET.fromstring(xml)
    
    for item in root.findall('SAT'):
        title = item.find('title').text
        print title
    


Answer: The method `Element.findall` uses xpath expression as an argument. `'SAT'`
finds only direct children that are named SAT of the root node, witch is
`'rss'`. If you need to find a tag anyway in the document use `'.//SAT'`.

The expression `'.//items'` is what you looking for:

    
    
    #!/usr/bin/python
    import lxml.etree as ET 
    import urllib2
    
    response = urllib2.urlopen('some/url/to.xml')
    xml = response.read()
    
    root = ET.fromstring(xml)
    
    for item in root.findall('.//item'):
        title = item.find('title').text
        print title
    

