How to parse YouTube XML using Python?
Question: I am trying to parse the xml from YouTube that is embedded in the code below.
I am trying to display all of the titles. However, I am running into trouble
when I try to print the 'title' only enter lines appear. Any advice?

    
    
    #import library to do http requests:
    import urllib2
    
    #import easy to use xml parser called minidom:
    from xml.dom.minidom import parseString
    #all these imports are standard on most modern python implementations
    
    #download the file:
    file = urllib2.urlopen('http://gdata.youtube.com/feeds/api/users/buzzfeed/uploads?v=2&max-results=50')
    #convert to string:
    data = file.read()
    #close file because we dont need it anymore:
    file.close()
    
    #parse the xml you downloaded
    dom = parseString(data)
    entry=dom.getElementsByTagName('entry')
    for node in entry:
        video_title=node.getAttribute('title')
        print video_title
    


Answer: Title is not an attribute, it is a child element of an entry.

here is an example how to extract it:

    
    
    for node in entry:
        video_title = node.getElementsByTagName('title')[0].firstChild.nodeValue
        print video_title
    

