|
Technical Interview Questions
Visual Basic Interview Question
ASP .NET Interview Questions
C++ Interview Questions
C
Interview Questions
.........More
Programming Source Codes
C/C++ Source Codes
C# Source Codes
.........More
Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
.........More
Tutorials
C Tutorial
C++ Tutorial
.........More
Soft Skills
Communication Skills
Leadership Skills
.........More
|
|
C# Source Codes
Writing an XML File using
the XMLTextWriter
using System.Xml;
string filename = "test2.xml";
XmlTextWriter tw = new XmlTextWriter(filename,null);
tw.Formatting = Formatting.Indented;
tw.WriteStartDocument();
tw.WriteStartElement("cd");
tw.WriteStartElement("genre","Rock and Roll");
tw.WriteAttributeString("SKU","3224554");
tw.WriteElementString("artist","Crystal Method");
tw.WriteElementString("title","Crash Vegas");
tw.WriteEndElement();
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();
The XML file generated can be found under your application directory in the
BIN\DEBUG directory. This is because we did not specify a folder path just a
filename.
XML File Output
<?xml version="1.0"?>
<cd>
<genre SKU="3224554" xmlns="Rock and Roll">
<artist>Crystal Method</artist>
<title>Crash Vegas</title>
</genre>
</cd>
<<<----- Return to
C# Source
Code Questions Page.
Have a Question ?
post your questions here. It
will be answered as soon as possible.
Check
Object Oriented Interview
Questions for more Object Oriented Interview Questions with answers
Check
Data Structure
Interview Questions for more data structure interview questions with
answers
|