4 using VERSION 1.3.0 native xml.etree.ElementTree for python3
5 appending method tostring serialize 'pretty_xml'
11 _versionPython = sys.version_info[0]
13 if _versionPython < 3:
14 # python2 previous historic mode
15 import src.ElementTreePython2 as etree
16 DBG.write("ElementTree Python2 %s" % etree.VERSION, etree.__file__, DBG.isDeveloper())
17 tostring = etree.tostring
21 # import xml.etree.ElementTree as etree # native version
22 import src.ElementTreePython3 as etree # VERSION 1.3.0 plus _serialize 'pretty_xml'
23 DBG.write("ElementTree Python3 %s" % etree.VERSION, etree.__file__, DBG.isDeveloper())
25 def tostring(node, encoding='utf-8'):
27 fix output as str with encoding='unicode' because python3
28 If encoding is "unicode", a string is returned.
29 Otherwise a bytestring is returned
32 aStr = etree.tostring(node, encoding='unicode', method="pretty_xml")
34 print("*****************************\n problem node", node)
36 aStr = etree.tostring(node, encoding='unicode')
38 # aStr = aStr.decode('utf-8')
42 Element = etree.Element