"Prasad PS" wrote: > In the code below, what I am doing is - I am opening an xml file and > appending a node to the root document. Then I add this root document to > the xml file > fp = open (string.strip(self.cnfDtls.GetLogFilePath()), 'w') > xml.dom.ext.PrettyPrint(doc, self.xmlFile) > self.xmlFile.write("\n") > fp.close(). > > So for each appending of node, the file is opened and the new root > document with the appeneded node is re-written to the file. This is > taking lot of time.
> Is there any way to append a node to the xml file without re-writing the > file? do you have to reload the file every time? (do you even have to save it every time?) a little profiling might also help; what part of the update process is taking most of the time (loading, updating, or saving). I would do load file while processing ... add node if enough time has elapsed (say, a second or two): save file if that's not efficient enough, you might have use a custom XML writer (you cannot just append to an XML file, since the end tag must be last in the file. you could open the file, read backwards until you find the start of the end tag, overwrite another node, and put the end tag back again. or you could use a custom writer that keeps track of where the end tag is, and overwrites it every time a new node is added) </F> _______________________________________________ XML-SIG maillist - XML-SIG@python.org http://mail.python.org/mailman/listinfo/xml-sig