Skip to content

Instantly share code, notes, and snippets.

@ebubekirbastama
Last active October 24, 2024 01:16
Show Gist options
  • Save ebubekirbastama/6d17b9e5b4f6215da71b49a6a9274166 to your computer and use it in GitHub Desktop.
Save ebubekirbastama/6d17b9e5b4f6215da71b49a6a9274166 to your computer and use it in GitHub Desktop.
using System;
using System.Xml;
class Program
{
static void Main()
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement root = xmlDoc.CreateElement("Stok");
xmlDoc.AppendChild(root);
// Ürünleri ekleyelim
XmlLinkedNode urun1 = xmlDoc.CreateElement("Urun");
urun1.Attributes.Append(xmlDoc.CreateAttribute("ID"));
urun1.Attributes["ID"].Value = "001";
urun1.Attributes.Append(xmlDoc.CreateAttribute("Adi"));
urun1.Attributes["Adi"].Value = "Laptop";
urun1.InnerText = "20"; // Stok miktarı
root.AppendChild(urun1);
XmlLinkedNode urun2 = xmlDoc.CreateElement("Urun");
urun2.Attributes.Append(xmlDoc.CreateAttribute("ID"));
urun2.Attributes["ID"].Value = "002";
urun2.Attributes.Append(xmlDoc.CreateAttribute("Adi"));
urun2.Attributes["Adi"].Value = "Akıllı Telefon";
urun2.InnerText = "35"; // Stok miktarı
root.AppendChild(urun2);
// XML'i yazdıralım
Console.WriteLine("Stok Yönetimi XML: " + xmlDoc.OuterXml);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment