下面的代碼會生成此錯誤。我無法弄清楚爲什麼。如果ElementTree解析,爲什麼它沒有tostring? http://docs.python.org/library/xml.etree.elementtree.html#xml.etree.ElementTree.ElementTree_ElementInterface實例沒有屬性'tostring'
from xml.etree.ElementTree import ElementTree
...
tree = ElementTree()
node = ElementTree()
node = tree.parse(open("my_xml.xml"))
text = node.tostring()
此代碼有效。謝謝。 – Alex