How to create Xml file with c# code?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaffreena Michaelthomas10 reputationPosted Apr 18, 2013, 3:42 AM EDT
The file gets saved inside the path specified,
-----------------------------------------------------------
if (TextBox1.Text != string.Empty)
{
string strXml = string.Empty;
strXml += "\n";
strXml += "
if (System.IO.File.Exists(Server.MapPath("~/XMLFile/" + TextBox1.Text + ".xml")))
{
System.IO.File.Delete(Server.MapPath("~/XMLFile/" + TextBox1.Text + ".xml"));
System.IO.StreamWriter file = new System.IO.StreamWriter(Server.MapPath("~/XMLFile/" + TextBox1.Text + ".xml"));
file.WriteLine(strXml);
file.Close();
file.Dispose();
}
else
{
System.IO.StreamWriter file = new System.IO.StreamWriter(Server.MapPath("~/XMLFile/" + TextBox1.Text + ".xml"));
file.WriteLine(strXml);
file.Close();
file.Dispose();
}
Shankar MRank #874 · 2.5K reputationPosted Apr 24, 2013, 9:33 PM EDT
Hope this will help you..
http://www.c-sharpcorner.com/Blogs/11446/extracting-xml-from-a-sql-server-using-dataset-class.aspx