我的代码看起来像
def read_zip_file():
import zipfile
zf = zipfile.ZipFile(os.path.expanduser('~/Downloads/tmp/me.zip'))
for filename in [ 'myfile.xml' ]:
print filename
try :
data = get_proposal_data_map(zf.read(filename))
print data
except:
logging.error('error - ' + str(sys.exc_info()))
这会将 xml 作为常规文件吐出。现在我有一个现有的代码,它给定一个路径将 XML 解析为
try:
tree = etree.parse(path)
root = tree.getroot()
for child in root:
# do things with XML
问题
我怎样才能parse
成为zipped XML (myfile.xml.zip)
常规XML
文件?