of*****@yahoo.no wrote:
: On 5 Mar, 14:23, ofuu...@yahoo.no wrote:
: Hi,
: Is there anyway I can append a new element to an existing xml without
: first loading the existing file into a variable, adding the new
: element into the variable and saving it by overwriting the existing
: file name?
If your concern is the physical act of efficiently adding data to an
existing file (such as what happens to log files) then I think the two
ways to do this would be
-1- Dont add the closing tag until you're finished adding data to the
file. Simply append each xml-snippet as needed. If you need to manipulate
the file before you're done then create a copy that has a closing tag.
-2- Each time you prepend the next set of data you need to truncate the
file slightly to remove the last line (containing the closing tag). If
the closing tag is a constant then you know the length to truncate,
otherwise you need to examine the last N bytes to find the location of the
last tag, and truncate enough bytes to remove it before appending the new
data.
$0.10