diff options
| -rw-r--r-- | libmat2/office.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libmat2/office.py b/libmat2/office.py index f796932..d067128 100644 --- a/libmat2/office.py +++ b/libmat2/office.py | |||
| @@ -283,9 +283,15 @@ class MSOfficeParser(ZipParser): | |||
| 283 | for children in element.iterfind('./*'): | 283 | for children in element.iterfind('./*'): |
| 284 | elements_ins.append((element, position, children)) | 284 | elements_ins.append((element, position, children)) |
| 285 | break | 285 | break |
| 286 | |||
| 286 | for (element, position, children) in elements_ins: | 287 | for (element, position, children) in elements_ins: |
| 287 | parent_map[element].insert(position, children) | 288 | parent_map[element].insert(position, children) |
| 288 | parent_map[element].remove(element) | 289 | |
| 290 | # the list can sometimes contain duplicate elements, so don't remove | ||
| 291 | # until all children have been processed | ||
| 292 | for (element, position, children) in elements_ins: | ||
| 293 | if element in parent_map[element]: | ||
| 294 | parent_map[element].remove(element) | ||
| 289 | 295 | ||
| 290 | tree.write(full_path, xml_declaration=True, encoding='utf-8') | 296 | tree.write(full_path, xml_declaration=True, encoding='utf-8') |
| 291 | return True | 297 | return True |
