I am using ElementTree. I have a parsed xml document that looks like this:
<data>
<name>
<slash>/</slash>
</name>
</data>
I would like to be able to save it using a hex code for the html escape character.
Since the hex code for '/' is 2F, I would like to persist the xml as:
<data>
<name>
<slash>/</slash>
</name>
</data>
What is the pythonic way to do this? Ideally, I would like this to work:
import xml.etree.ElementTree as ET
xml_doc = ET.tostring(source,method="xml")
xml_doc=change_to_html_hex_code(xml_doc)
out_file = open("output.xml",'w')
out_file.write(xml_doc)