开发者

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:

  1. Create XmlDocument object of the file you need to modify
  2. Create the XmlNodeList ready ( you have that already)
  3. Use the AppendChild, InsertAfter or InsertBerfore methods ( these methods accept only XmlNode so you will have to iterate)
  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜