C#でXMLファイルを動的に作成し、指定したパスに保存する方法

4035 ワード

     using System.Xml;  //     

     ///
/// C# XML /// public void CreateXML() { XmlDocument doc = new XmlDocument(); // XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.AppendChild(dec); // // XmlElement typeB = doc.CreateElement("typeB"); typeB.SetAttribute("version", "1.0"); // doc.AppendChild(typeB); // // XmlElement programList = doc.CreateElement("ProgramList"); // programList typeB.AppendChild(programList); // typeB XmlElement playTime = doc.CreateElement("PlayTime"); // playTime playTime.InnerXml = "2018"; // programList.AppendChild(playTime); // programList // doc.Save(" .xml"); // , Bin\DeBug MessageBox.Show(""); }