I need to append data to a pre-existing xml file.
We run a process and write out a certain amount of information in the beginning. The we need to append data to the file as long as the process is running.
My file will look something like this
<Main Tag>
<BeginningData value="This is the data added in the beginning"/>
<Items>
<Item description="Data incrementatlly added" value = "1"/>
<Item description="Data incrementatlly added" value = "2"/>
</Items>
</Main Tag>
The problems I have are these -
1. I don't know a way to write the information out so that the xml file is NOT well formed. If I can write it out so that the ending tag (ie if my file does NOT have </Main Tag>) I can just write out the incremental data and then at the end of the process - write out the ending tag.
2. If the ending tag exists - how do I write out the incremental data. I don't want to use the XmlDocument object to load the file, add the data and then re-write the entire object out because these files get really big. The only other solution I know of is to use the XmlTextReader and XmlTextWriter - seek to the end of the file - find the beginning of the end tag and then overwrite it. This solution is a big brittle and I don't want to use it if possible.
Thanks
We run a process and write out a certain amount of information in the beginning. The we need to append data to the file as long as the process is running.
My file will look something like this
<Main Tag>
<BeginningData value="This is the data added in the beginning"/>
<Items>
<Item description="Data incrementatlly added" value = "1"/>
<Item description="Data incrementatlly added" value = "2"/>
</Items>
</Main Tag>
The problems I have are these -
1. I don't know a way to write the information out so that the xml file is NOT well formed. If I can write it out so that the ending tag (ie if my file does NOT have </Main Tag>) I can just write out the incremental data and then at the end of the process - write out the ending tag.
2. If the ending tag exists - how do I write out the incremental data. I don't want to use the XmlDocument object to load the file, add the data and then re-write the entire object out because these files get really big. The only other solution I know of is to use the XmlTextReader and XmlTextWriter - seek to the end of the file - find the beginning of the end tag and then overwrite it. This solution is a big brittle and I don't want to use it if possible.
Thanks