0

I get TypeError: Type 'NoneType' cannot be serialized.while reading the following xml file

<root>
 <sub_component> 
     Hii & heloo <> 
 </sub_component>
</root>

The code I use for coding is as follows

from lxml import etree
parser = etree.XMLParser(recover=True) # recover from bad characters.
root = etree.fromstring(file_path, parser=parser)
print etree.tostring(root)
Jim Garrison
  • 83,534
  • 20
  • 149
  • 186
athira
  • 127
  • 2
  • 10

1 Answers1

0

You can use BeautifulSoup:

from bs4 import BeautifulSoup

soup= BeautifulSoup(xml_string, 'html.parser')
Aran-Fey
  • 35,525
  • 9
  • 94
  • 135