import xml.dom.minidomdef parseXMLFile(filename): doc = xml.dom.minidom.parse(filename) try: root = doc.documentElement # make sure this is a valid xml file if (not root or root.tagName != 'ut_response status'): raise # make sure <video_list> block exists video_list = self.FirstChildElement(root, 'video_list') if (not video_list or not video_list.firstChild): raise # parse and resolve each <video> data = video_list.getElementsByTagName('video') if (not data): raise for video in data: node = self.FirstChildElement(tmp, None) while (node): # key node get value if (node.tagName.lower() == 'title' and node.hasChildNodes()): title = node.firstChild.nodeValue elif (node.tagName.lower() == 'url' and node.hasChildNodes()): url = node.firstChild.nodeValue node = node.nextSibling except: pass