48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
using System.Xml.Linq;
|
|
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 1953"
|
|
public string[] Keys { get; set; } //z.B. "UGII_ENV"
|
|
public string[] Values { get; set; } //z.B. "M:\ug\NX1953_NXTC\global\00_DEFAULTS\UGII\ugii_env.dat"
|
|
|
|
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 i = 0; i < Values.Length; i++)
|
|
{
|
|
XElement groupElement = new XElement(ns + Group.Replace(" ", "_"));
|
|
groupElement.Add(new XAttribute(Keys[i], Values[i]));
|
|
|
|
rootElement.Add(groupElement);
|
|
}
|
|
|
|
rootElement.Save(FileName);
|
|
|
|
MessageBox.Show(AppRes.msgBoxTxt003, AppRes.msgBoxCapt003, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
}
|
|
}
|