Escape unescaped characters in XML with Python

I need to escape special characters in an invalid XML file which is about 5000 lines long. Here's an example of the XML that I have to deal with:


 
  name & surname
  name@name.org
 

Here the problem is the character "&" in the name. How would you escape special characters like this with a Python library? I didn't find a way to do it with BeautifulSoup.

7
задан Acumenus 11 August 2019 в 14:09
поделиться