Parse XML with (X)HTML entities

后端 未结 2 1193
闹比i
闹比i 2021-01-04 02:16

Trying to parse XML, with ElementTree, that contains undefined entity (i.e.  ) raises:

ParseError: undefined entity  

2条回答
  •  無奈伤痛
    2021-01-04 03:07

    I was having a similar issue and got around it by using lxml. Its etree.XMLParser has a recover keyword argument which forces it to try to ignore broken XML.

提交回复
热议问题