I am running a program (via py2exe) that is reading some XML files with xml.minidom. I am getting an error wherein I pull a value from a tag which (I think) happens to be empty. Thus, it throws this error:
AttributeError: 'NoneType' object has no attribute 'data' Here's the code that creates this problem: def functionname(fileobject): try: xmldoc = minidom.parse(fileobject) except xml.parsers.expat.ExpatError, AttributeError: logit = "There is a malformed file: " + fileobject + "\n" logfile.write(logit) else: a = xmldoc.getElementsByTagName('date_modified') try: b = a[0].firstChild.data except xml.parsers.expat.ExpatError, AttributeError: logit = "There is a malformed file: " + fileobject + "\n" logfile.write(logit) I am wondering what I have to do to catch this exception - I'm assuming that the problem is that "a" is an empty object, and so it has not attributes. Thanks. -- yours, William _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor