I want to search a .xlsx file for a certain XML tag - for example, to check if there exists an tag anywhere in the .xlsx file.
My current plan is to un-zip the .xlsx file and then search all .xml files for the tag in question. Is there a standard library for this, or an easier way to do this?
def xlsxHasEntity(filename):
input_zip = ZipFile(filename)
xml_files = [name for name in input_zip.namelist() if name.endswith("xml")]
raw_files = {name: input_zip.read(name) for name in xml_files}
for raw_filename in raw_files:
if "<!ENTITY" in raw_files[raw_filename]:
return True
return False
The above is my current solution which seems to be working. Thought I'd share it in case anyone comes to this question in the future.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.