C# XML Dosyasını Yazacak Program

feneresevdalı

Kilopat
Katılım
23 Temmuz 2019
Mesajlar
8.652
Makaleler
7
Çözümler
30
Daha fazla  
Sistem Özellikleri
CPU: AMD Ryzen 5 4650G
GPU: RX Vega 7
RAM: 2x8 Goodram 3600 MHz CL 18
SSD: Kingston A2000 500 GB M.2 NVME
PSU: FSP Hyper K 500w 800+
Cinsiyet
Erkek
Office 2019'u Microsoft serverlarından çekip yükleyen bir program hazırlıyorum.

1585465791787.png


Programın görsel arayüzü bu şekilde. Ancak seçimlere göre oluşacak xml dosyasını yazmayı bir türlü beceremiyorum. Bana ekteki xml dosyasını yazabilen bir kod yazabilir misiniz? Bu temel xml dosyası ben bunu seçimlere uygun formata çekmek istiyorum.
 
C#:
using System.Xml.Linq;

// ...

public void GetXML() {
    var doc = XDocument.Parse(
$@"<Configuration ID="190e515a-6490-4b3f-af00-c43ebedcf951">
  <Add OfficeClientEdition="{(mimari64CheckBox.Checked ? "64" : "32")}" Channel="Broad">
    <Product ID="O365ProPlusRetail">
      <Language ID="tr-tr" />
    </Product>
  </Add>
  <Property Name="SharedComputerLicensing" Value="0" />
  <Property Name="PinIconsToTaskbar" Value="TRUE" />
  <Property Name="SCLCacheOverride" Value="0" />
  <Property Name="AUTOACTIVATE" Value="0" />
  <Property Name="FORCEAPPSHUTDOWN" Value="FALSE" />
  <Property Name="DeviceBasedLicensing" Value="0" />
  <Updates Enabled="TRUE" />
  <RemoveMSI />
</Configuration>"
    );
    if(accessCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Access"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(excelCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Excel"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(grooveCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Groove"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(lyncCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Lync"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(onedriveCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","OneDrive"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(onenoteCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","OneNote"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(OutlookCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Outlook"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(powerpointCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","PowerPoint"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(publisherCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Publisher"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(teamsCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Teams"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
    if(wordCheckBox.Checked) {
        var element = new XElement("ExcludeApp");
        element.Add(new XAttribute("ID","Word"));
        doc.Root.Element("Add").Element("Product").Add(element);
    }
}

Çoooook daha iyisi yapılabilir, amatörce bir kod. Ama o da senin işin aslında bunu bile atmam lazım da, atıyorum işte.
 
Uyarı! Bu konu 5 yıl önce açıldı.
Muhtemelen daha fazla tartışma gerekli değildir ki bu durumda yeni bir konu başlatmayı öneririz. Eğer yine de cevabınızın gerekli olduğunu düşünüyorsanız buna rağmen cevap verebilirsiniz.

Geri
Yukarı