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?
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?
精彩评论