ParseError: not well-formed (invalid token) using cElementTree

前端 未结 13 1078
日久生厌
日久生厌 2020-12-16 11:10

I receive xml strings from an external source that can contains unsanitized user contributed content.

The following xml string gave a ParseError in cElementTre

13条回答
  •  鱼传尺愫
    2020-12-16 11:45

    See this answer to another question and the according part of the XML spec.

    The backspace U+0008 is an invalid character in XML documents. It must be represented as escaped entity  and cannot occur plainly.

    If you need to process this XML snippet, you must replace \x08 in s before feeding it into an XML parser.

提交回复
热议问题