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)
2
  • That is not valid XML Commented Jul 20, 2016 at 5:16
  • unfortunately I have a file like this and it need to be processed.. Any means for doing that? Commented Jul 20, 2016 at 8:40

1 Answer 1

0

You can use BeautifulSoup:

from bs4 import BeautifulSoup

soup= BeautifulSoup(xml_string, 'html.parser')
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.