diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-12-05 19:29:10 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-12-05 19:29:10 +0000 |
| commit | 414cb49cd08d4952cf5eff51bd9e2da811c4661b (patch) | |
| tree | b237b5f402d7f7f5f80c6c93bc1c3415e9cfe146 /mammoth/docx/xmlparser.py | |
| parent | 3646167ab5685ea5a69de24442cf46e963bf7f41 (diff) | |
Revert "Handle XML documents that are missing a root element"
This reverts commit 659c4ffe6ade2d8132873ae3f3f3a22df38fdb37.
Diffstat (limited to 'mammoth/docx/xmlparser.py')
| -rw-r--r-- | mammoth/docx/xmlparser.py | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/mammoth/docx/xmlparser.py b/mammoth/docx/xmlparser.py index d78e610..1ba415d 100644 --- a/mammoth/docx/xmlparser.py +++ b/mammoth/docx/xmlparser.py @@ -1,5 +1,4 @@ import xml.dom.minidom -import xml.parsers.expat.errors import cobble @@ -75,9 +74,6 @@ XmlElement.node_type = node_types.element XmlText.node_type = node_types.text -class NoRootElementError(Exception): - pass - def parse_xml(fileobj, namespace_mapping=None): if namespace_mapping is None: @@ -85,13 +81,7 @@ def parse_xml(fileobj, namespace_mapping=None): else: namespace_prefixes = dict((uri, prefix) for prefix, uri in namespace_mapping) - try: - document = xml.dom.minidom.parse(fileobj) - except xml.parsers.expat.ExpatError as error: - if error.code == xml.parsers.expat.errors.codes[xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS]: - raise NoRootElementError() - else: - raise + document = xml.dom.minidom.parse(fileobj) def convert_node(node): if node.nodeType == xml.dom.Node.ELEMENT_NODE: |
