Xml write to end

  • Thread starter Thread starter Varangian
  • Start date Start date
V

Varangian

Hello

I want to Write XML to an already existing XML file at the end of this
file

however I'm at a loss on how to do that...

whats the best way?

Thanks
 
Hello
I want to Write XML to an already existing XML file at the end of this
file

however I'm at a loss on how to do that...

whats the best way?

Thanks

You can't just write to the end of an XML file and end up with a valid
file, as the end-tag of the root-node should remain the last xml-item
in the file.

So either you should read the file into an XmlDocument, add the node(s)
and write the complete file.
Or you might be able to use an XmlReader and XmlWriter to copy the XML
to a new (temporary) file and add the new XML at the right moment.
Remove the old file and rename the temp file.

Hans Kesting
 
Varangian said:
I want to Write XML to an already existing XML file at the end of this
file

however I'm at a loss on how to do that...

You need two files then, one an XML document defining and referencing
the second as an external entity. Then append anything to the external
entity as needed while the main XML document has the root element as a
wrapper for the entity.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top