Use XmlTextWriter to create Xml document : XmlTextWriter « XML « C# / C Sharp






Use XmlTextWriter to create Xml document

 

using System;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;

public class MainClass{
   public static void Main(){
         XmlTextWriter w = new XmlTextWriter(Console.Out);
         w.WriteStartElement("root");
         w.WriteAttributeString("xmlns", "x", null, "urn:1");
         w.WriteStartElement("item","urn:1");
         w.WriteEndElement();
         w.WriteStartElement("item","urn:1");
         w.WriteEndElement();
         w.WriteEndElement();
   }
}

   
  








Related examples in the same category

1.Write attribute
2.Close an element
3.Control the formatting
4.Write the double value out
5.Closes this stream and the underlying stream.
6.Flush what is in the buffer to the underlying streams and flush the underlying stream.
7.XmlTextWriter.Indentation Property gets or sets how many IndentChars to write
8.XmlTextWriter.LookupPrefix returns the closest prefix in the current namespace scope
9.XmlTextWriter.WriteCData writes out a block containing the specified text.
10.Use specified Unicode character value.
11.Closes one element and pops the corresponding namespace scope.
12.Writes out the namespace-qualified name.
13.Writes raw markup manually from a string.
14.Writes out the given white space.