XML Write: comment, start element, end element, attribute : XML Write « XML « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Date Time
8.Design Patterns
9.Development Class
10.Event
11.File Stream
12.Generics
13.GUI Windows Form
14.Internationalization I18N
15.Language Basics
16.LINQ
17.Network
18.Office
19.Reflection
20.Regular Expressions
21.Security
22.Services Event
23.Thread
24.Web Services
25.Windows
26.Windows Presentation Foundation
27.XML
28.XML LINQ
C# Book
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » XML » XML WriteScreenshots 
XML Write: comment, start element, end element, attribute
 
using System;
using System.Xml;

public class TestXMLWriter{
  static void Main(string[] args)
  {
    XmlTextWriter writer = new XmlTextWriter("test.xml"new System.Text.ASCIIEncoding());
    writer.Formatting = Formatting.Indented;
    writer.Indentation = 4;
    writer.WriteStartDocument();
    writer.WriteComment("Comment");
    writer.WriteStartElement("ElementName""myns");
    writer.WriteStartAttribute("prefix""attrName""myns");
    writer.WriteEndAttribute();
    writer.WriteElementString("ElementName""myns""value");
    writer.WriteEndElement();
    writer.WriteEndDocument();
    writer.Flush();
    writer.Close();
  }
}



           
         
  
Related examples in the same category
1.Create XML document with XmlWriter
2.Read and Write XML Without Loading an Entire Document into MemoryRead and Write XML Without Loading an Entire Document into Memory
3.Writing XML with the XmlWriter ClassWriting XML with the XmlWriter Class
4.Write To XML File
5.Illustrates the XmlTextWriter class
6.Write XML document to console
7.Create XmlWriter using the static XmlWriter.Create method.
w___ww___.jav_a_2___s_.___com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.