I created a small tool for my job, it parses xml files to find the text of an element; example code:
import xml.etree.cElementTree as Etree
def open_xml():
"""
Retrieves info from the xml file
"""
try:
tree = Etree.parse("xml_file.xml")
text_to_find = tree.findtext(
path=".//ns:some_element",
namespaces={"ns": "http://something.com/something"})
print text_to_find
except IOError:
print "No xml file found."
This is part of a gui; we never close the app, it's always running on a dedicated computer.
If I understand correctly, python creates an object in memory representing the xml tree. My question is: do I need to clear the memory of that object after I'm done printing the info? I'm worried that we're using more and more memory each time we parse an xml file...