Appending an existing XML file

后端 未结 3 2025
一生所求
一生所求 2020-12-11 08:55

I have an existing XML file that I would like to append without changing the format. Existing File looks like this:


  

        
3条回答
  •  感动是毒
    2020-12-11 09:30

    You should use the XmlDocument class to load the whole file, modify it in memory and then write the contents back replacing the original file. Don't worry, it won't mess up your markup, and you can even ask it to preserve non-significant whitespace in the original document using the PreserveWhitespace property (http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.preservewhitespace.aspx).

提交回复
热议问题