All pastes #187449 Raw Edit

Anonymous

public python v1 · immutable
·published 2006-10-01 03:28 UTC
rendered paste body
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