diff options
| -rw-r--r-- | libmat2/office.py | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index 1ececdf..c6c4688 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -22,17 +22,11 @@ assert Pattern | |||
| 22 | logging.basicConfig(level=logging.ERROR) | 22 | logging.basicConfig(level=logging.ERROR) |
| 23 | 23 | ||
| 24 | def _parse_xml(full_path: str): | 24 | def _parse_xml(full_path: str): |
| 25 | """ This function parse XML with namespace support. """ | 25 | """ This function parse XML, with namespace support. """ |
| 26 | def parse_map(f): # etree support for ns is a bit rough | ||
| 27 | namespace_map = dict() | ||
| 28 | for _, (key, value) in ET.iterparse(f, ("start-ns", )): | ||
| 29 | namespace_map[key] = value | ||
| 30 | return namespace_map | ||
| 31 | 26 | ||
| 32 | namespace_map = parse_map(full_path) | 27 | namespace_map = dict() |
| 33 | 28 | for _, (key, value) in ET.iterparse(full_path, ("start-ns", )): | |
| 34 | # Register the namespaces | 29 | namespace_map[key] = value |
| 35 | for key, value in namespace_map.items(): | ||
| 36 | ET.register_namespace(key, value) | 30 | ET.register_namespace(key, value) |
| 37 | 31 | ||
| 38 | return ET.parse(full_path), namespace_map | 32 | return ET.parse(full_path), namespace_map |
