using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using System.Windows.Forms; using AppRes = Eugen.ESystem.Windows.Forms.Properties.AppResources; namespace Eugen.ESystem.Windows.Forms { internal class SaveXML { public string FileName { get; set; } public string Topic = ""; //z.B. "NX-Portal" public string Group { get; set; } //z.B. "NX" public string GroupStandard { get; set; } //z.B. "Standardversion" public string Key { get; set; } //z.B. "Key" public string[] Values { get; set; } //z.B. "NX 1953" public int Standard { get; set; } //z.B. "2" public void Save() { //Namensraum definieren XNamespace ns = "https://www.engelglobal.com/de/at/index.html"; //Wurzelelement erzeugen XElement rootElement = new XElement(ns + Topic); //Namensraum als Attribut angeben rootElement.Add(new XAttribute("xmlns", ns)); //Der Wert for (int id = 0; id < Values.Length; id++) { XElement groupElement = new XElement(ns + Group); groupElement.Add(new XAttribute("Id", id + 1)); groupElement.Add(new XAttribute(Key, Values[id])); if (Standard == id + 1) { groupElement.Add(new XAttribute("Standard", "yes")); } else { groupElement.Add(new XAttribute("Standard", "no")); } rootElement.Add(groupElement); } //XElement standardElement = new XElement(ns + GroupStandard); //standardElement = new XElement(ns + GroupStandard); //standardElement.Add(new XAttribute("Standard", Standard)); //rootElement.Add(standardElement); rootElement.Save(FileName); MessageBox.Show(AppRes.msgBoxTxt003, AppRes.msgBoxCapt003, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }