writing xml contents to a file
How to write the contents of the "XmlNodeList" in a separate xml file(ie.,the contents should be appende开发者_运维技巧d at the end of a file,if the file already contains some text)?
If you know the XML ( I assume you do!) you can do the following steps:
- Create XmlDocument object of the file you need to modify
- Create the XmlNodeList ready ( you have that already)
- Use the AppendChild, InsertAfter or InsertBerfore methods ( these methods accept only XmlNode so you will have to iterate)
- Save the XmlDocument
Hope this helps,
Regards,
Abdel Olakara
Load the XML document. Find the node where you want to insert new block. Insert the block. Write the XML to the file.
Use XmlDocument class for this purpose. Check MSDN for examples.
精彩评论