Mega Code Archive

 
Categories / C# Tutorial / XML
 

Write value to Xml

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Xml;     public class MainClass     {         public static void Main()         {             XmlWriter writer;             writer = XmlWriter.Create("output.xml");             writer.WriteStartDocument();             writer.WriteStartElement("pubs");             writer.WriteStartElement("titles");             writer.WriteStartAttribute("name");             writer.WriteValue("value");             writer.WriteEndAttribute();             writer.WriteStartAttribute("price");             writer.WriteValue(19.99);             writer.WriteEndAttribute();             writer.WriteEndElement();             writer.Close();         }     }