usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Xml;
namespaceXml_Create
{
classProgram
{
staticvoidMain(string[]args)
{
using(XmlTextWritertxtwrite=newXmlTextWriter(@"G:\\Students.xml",null))
{
txtwrite.WriteStartDocument();
txtwrite.WriteComment("Students.xmlFileCreatedUsingXmlTextWriter");
txtwrite.WriteStartElement("StudentDetails");
txtwrite.WriteStartElement("Student");
txtwrite.WriteAttributeString("StudentID","001");
txtwrite.WriteElementString("Name","cjn");
txtwrite.WriteElementString("Marks","90");
txtwrite.WriteEndElement();
txtwrite.WriteStartElement("Student");
txtwrite.WriteAttributeString("StudentID","002");
txtwrite.WriteElementString("Name","wan");
txtwrite.WriteElementString("Marks","99");
txtwrite.WriteEndElement();
txtwrite.WriteEndElement();
txtwrite.WriteEndDocument();
txtwrite.Close();
}
}
}
}
|
|