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
  • 85,615
  • 20
  • 155
  • 190
athira
  • 167
  • 1
  • 2
  • 10

1 Answers1

0

You can use BeautifulSoup:

from bs4 import BeautifulSoup

soup= BeautifulSoup(xml_string, 'html.parser')
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149