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