views:

37

answers:

1

Hi, If I want to store data about a certain resource in an XML file but for speed sake I don't want to first read the file and then re-write it, I want to append to existing file. But if it's a valid XML file than it has to have only a single root element, and if it's closed, than appending new node will be make XML file invalid. Any suggestions for what to do?

+1  A: 

You did not write which programming language you want to use. In C, open the file with 'r+' flag, navigate to the beginning of the end tag, then write the new element and the end tag.
On the other hand, probably this is the case when you should use plain text file, instead of XML. Is there a reason it has to be XML?

Miklos
yes, 'cause it will have a lot of arbitrary data fields (that's also the reason not to use SQL)
SODA