reads in a kmz file and returns xml nodes

def readkmz(self, filename):
        '''reads in a kmz file and returns xml nodes'''
        #Strip quotation marks if neccessary
        filename.strip('"')
        #Open the zip file (as applicable)    
        if filename[-4:] == '.kml':
            fo = open(filename, "r")
            fstring = fo.read()
            fo.close()
        elif filename[-4:] == '.kmz':
            zip=ZipFile(filename)
            for z in zip.filelist:
                if z.filename[-4:] == '.kml':
                    fstring=zip.read(z)
                    break
            else:
                raise Exception("Could not find kml file in %s" % filename)
        else:
            raise Exception("Is not a valid kml or kmz file in %s" % filename)
                
        #send into the xml parser
        kmlstring = parseString(fstring)

        #get all the placenames
        nodes=kmlstring.getElementsByTagName('Placemark')
        
        return nodes