Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

XMLWriter write xml C#

using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {
     XmlTextWriter writer = new XmlTextWriter("Shopping_list.xml", null);

     //Write the root element
     writer.WriteStartElement("The_list");

     //Write sub-elements
     writer.WriteElementString("Fruit", "Banana");
     writer.WriteElementString("Vegetable", "Carrot");
     writer.WriteElementString("Drink", "Water");

     // end the root element
     writer.WriteEndElement();

     //Write the XML to file and close the writer
     writer.Close();
  }
}
Source by www.codeguru.com #
 
PREVIOUS NEXT
Tagged: #XMLWriter #write #xml
ADD COMMENT
Topic
Name
9+4 =