C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Writing an XML document using XmlTextWriter


Posted Date: 23 Aug 2008    Resource Type: Code Snippets    Category: XML
Author: Kundan Kumar SinhaMember Level: Gold    
Rating: Points: 10



The XmlWriter class contains the functionality to write to XML documents.
It is an abstract base class used through XmlTextWriter and XmlNodeWriter classes.
It contains methods and properties to write to XML documents.


' Import System.Xml namespace
Imports System.Xml
Module Module1
Sub Main()
' Create a new file in C:\\ dir
Dim textWriter As XmlTextWriter = New XmlTextWriter("C:\\myXmFile.xml", Nothing)
' Opens the document
textWriter.WriteStartDocument()
' Write comments
textWriter.WriteComment("First Comment XmlTextWriter Sample Example(")")textWriter.WriteComment("myXmlFile.xml in root dir")
' Write first element
textWriter.WriteStartElement("Student")
textWriter.WriteStartElement("r", "RECORD", "urn:record")
' Write next element
textWriter.WriteStartElement("Name", "")
textWriter.WriteString("Student")
textWriter.WriteEndElement()
' Write one more element
textWriter.WriteStartElement("Address", "")
textWriter.WriteString("Colony")
textWriter.WriteEndElement()
' WriteChars
textWriter.WriteStartElement("Char")
Dim ch() As Char = {"b", "l", "last"}
textWriter.WriteChars(ch, 0, ch.Length)
textWriter.WriteEndElement()
' Ends the document.
textWriter.WriteEndDocument()
' close writer
textWriter.Close()
End Sub
End Module




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Writing an XML document using XmlTextWriter  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Edit XML Element
Previous Resource: Insert Update Delete With XML file in c#
Return to Discussion Resource Index
Post New Resource
Category: XML


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use