Sayfayı Yazdır | Pencereyi Kapat

XML oluşturmak

Nereden Yazdırıldığı: Datakent
Kategori: Diğer bölümler
Forum Adı: C# & ASP.NET
Forum Tanımlaması: C# ve ASP.NET ile ilgili soru / sorun ve paylaşım bölümü
URL: http://forum.datakent.com/forum_posts.asp?TID=2285
Tarih: 04.Mayis.2024 Saat 04:15


Konu: XML oluşturmak
Mesajı Yazan: murat turan
Konu: XML oluşturmak
Mesaj Tarihi: 27.Aralik.2011 Saat 12:55
            // Create the xml document containe
            XmlDocument doc = new XmlDocument();// Create the XML Declaration, and append it to XML document
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0"nullnull);
            doc.AppendChild(dec);// Create the root element
            XmlElement root = doc.CreateElement("Library");
            doc.AppendChild(root);
 
            // Create Books
            // Note that to set the text inside the element,
            // you use .InnerText instead of .Value (which will throw an exception).
            // You use SetAttribute to set attribute
            XmlElement book = doc.CreateElement("Book");
            book.SetAttribute("BookType""Hardcover");
 
            XmlElement title = doc.CreateElement("Title");
            title.InnerText = "Door Number Three";
 
            XmlElement author = doc.CreateElement("Author");
            author.InnerText = "O'Leary, Patrick";
 
            book.AppendChild(title);
            book.AppendChild(author);
            root.AppendChild(book);
 
            string xmlOutput = doc.OuterXml;
 
            //sonuc asagidaki gibi olacaktir...
            //<?xml version="1.0"?>
            //<Library>
            //    <Book BookType="Hardcover">
            //        <Title>Door Number Three</Title>
            //        <Author>O'Leary, Patrick</Author>
            //    </Book>
            //</Library>
 


-------------
http://www.kasatakip.com - Kasa Takip  |  http://www.caritakip.com - Cari Takip  |  http://www.evraktakip.com - Evrak Takip  |  http://www.etasqlmobil.com - ETA SQL Mobil



Sayfayı Yazdır | Pencereyi Kapat