xml.dom.minidom.Node.unlink()

Node.unlink()

Break internal references within the DOM so that it will be garbage collected on versions of Python without cyclic GC. Even when cyclic GC is available, using this can make large amounts of memory available sooner, so calling this on DOM objects as soon as they are no longer needed is good practice. This only needs to be called on the Document object, but may be called on child nodes to discard children of that node.

You can avoid calling this method explicitly by using the with statement. The following code will automatically unlink dom when the with block is exited:

with xml.dom.minidom.parse(datasource) as dom:
    ... # Work with dom.
doc_python
2016-10-07 17:47:48
Comments
Leave a Comment

Please login to continue.