Last active
December 6, 2022 14:22
-
-
Save daaniam/00846497d044ac063cf17047d67f3b93 to your computer and use it in GitHub Desktop.
example: Locate xml element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_files_from_xml(xml_element: etree.Element) -> list[BytesIO]: | |
"""Extract files from XML element""" | |
output = [] | |
elements_with_file = ["bArray", "ByteArray"] | |
for file_element in elements_with_file: | |
# Locate element | |
for element_with_file in xml_element.xpath(f'//*[local-name()="{file_element}"]'): | |
print('element with file', element_with_file) | |
# Add found element to output | |
output.append(BytesIO(element_with_file)) | |
return output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment