Xml Line Break Character Entity And Python Encoding
I have the following line of code in a python script: dep11 = ET.SubElement(dep1, 'POVCode').text = '#declare lg_quality = LDXQual;
#if (lg_quality = 3)
#declare
Solution 1:
What I eventually did was use the standard Python write
function instead of using ElementTree's own write
function.
text = ET.tostring(root).replace("&&", "&")
with open("LGEO.xml", "wb") as f:
f.write(text.encode("utf-8"))
The above is the last step in the Python code. I don't know if there are disadvantages to converting the root object to a string like this. It could be slower but it works for me.
Post a Comment for "Xml Line Break Character Entity And Python Encoding"