Save Xml Document - CSharp System.Xml

CSharp examples for System.Xml:XML Document

Description

Save Xml Document

Demo Code


using System.Xml;
using System.Collections.Generic;
using System;// w  w w  .  jav a2s  .com

public class Main{
        public static void SaveXmlDocument(string xmlFilePath, List<Dictionary<string, string>> elements)
        {
            XmlDocument xml = LoadXmlDocument(xmlFilePath);
            xml.RemoveAll();
            xml = AddXmlHeader(xml, "GameList");
            for (int i = 0; i < elements.Count; i++) {
                xml = AddElement(xml, "Game", elements[i]);
            }
            xml.Save(xmlFilePath);
        }
        public static void SaveXmlDocument(XmlDocument xml, string xmlFilePath) {
            xml.RemoveAll();
            xml = AddXmlHeader(xml, "GameList");
            xml.Save(xmlFilePath);
        }
}

Related Tutorials