from xml.etree.ElementTree import ElementTree, Element, SubElement, dump
elem = Element('1')
sub = SubElement(elem, '2')
tree = ElementTree(elem)
dump(tree)
dump(elem)
In the code above, dumping tree (which is an ElementTree) and dumping elem (which is an Element) results in the same thing. Therefore I am having trouble determining what the difference is between the two.
dump()
function works the same forElementTree
andElement
because it was intentionally made to behave this way:ElementTree
is a wrapper class that corresponds to the "entire element hierarchy" providing serialization functionality - dumping and loading the tree.Element
, on the other hand, is a much "bigger" class that defines theElement
interface.