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 !




Create XML


Posted Date: 18 Jul 2008      Total Responses: 1

Posted By: Shweta       Member Level: Bronze     Points: 1



I want to create a Xml File i want to bind that xml file to one of the gridview columns in asp.net with Vb, how to create the XML and where can i provide the path
can any one help me plz . I am using static values for the XML file.





Responses

Author: Sabu C Alex    18 Jul 2008Member Level: GoldRating:     Points: 6

void CreateXmlFile(String xmlFilePath)
{
XmlTextWriter xmlWriter = new XmlTextWriter(xmlFilePath, Encoding.UTF8);
xmlWriter.WriteStartDocument(true);
xmlWriter.WriteStartElement("Departments"); //Root Element
xmlWriter.WriteStartElement("Department"); //Department Element
xmlWriter.WriteStartAttribute("Name"); //Attribute "Name"
xmlWriter.WriteString("Development"); //Attribute Value
xmlWriter.WriteEndAttribute();
xmlWriter.WriteStartElement("Employees"); //Started Employees Element
xmlWriter.WriteStartElement("Employee"); //Started Employee Element
xmlWriter.WriteStartAttribute("Name"); //Attribute "Name"
xmlWriter.WriteString("Sabu C.Alex"); //Attribute Value

xmlWriter.WriteEndAttribute();
xmlWriter.WriteStartAttribute("Age");//Attribute "Age"
xmlWriter.WriteString("28");//Attribute Value
xmlWriter.WriteEndAttribute();
xmlWriter.WriteString("Sabu C.Alex is working as a Software Engineer"); //Employee Element Inner Text
xmlWriter.WriteEndElement(); //End of Employee Element
xmlWriter.WriteStartElement("Employee"); //Started Employee Element
xmlWriter.WriteStartAttribute("Name"); //Attribute "Name"
xmlWriter.WriteString("Dinup Varghese"); //Attribute Value
xmlWriter.WriteEndAttribute();
xmlWriter.WriteStartAttribute("Age");//Attribute "Age"
xmlWriter.WriteString("28");//Attribute Value
xmlWriter.WriteEndAttribute();
xmlWriter.WriteString("Dinup Varghese is working as a Software Engineer"); //Employee Element Inner Text
xmlWriter.WriteEndElement(); //End of Employee Element
xmlWriter.WriteEndElement(); //End of Employees Element
xmlWriter.WriteEndElement(); //End of Department Element
xmlWriter.WriteEndElement(); //End of Root Element
xmlWriter.WriteEndDocument();
xmlWriter.Flush();
xmlWriter.Close();
}



Post Reply
You must Sign In to post a response.
Next : developing xml application
Previous : Ned to know about radio button propertis in XML
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use