Hello;
when I create xml file in C#, the file Created is in one line
My Question : How to create an xml file in several line format;
thank you
Hello;
when I create xml file in C#, the file Created is in one line
My Question : How to create an xml file in several line format;
thank you
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 attend4days leftRegister
Vijay Jadhav14 reputationPosted May 20, 2009, 2:41 AM EDT
Your question is very unclear.
But, if you want to create Xml file from desired string then following snippet will help you :
#region Create Xml File
/*----------------------- Create Xml String To Xml File ------------------------*/
private void CreateXmlFile(string sStudentXml)
{
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(sStudentXml);
doc.Save(Server.MapPath("XmlFiles\\ReadXml.xml"));
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
Also here is some tutorial :
1) http://www.c-sharpcorner.com/UploadFile/mahesh/writexmlusingXmlWriter11132005233450PM/writexmlusingXmlWriter.aspx
2) http://www.c-sharpcorner.com/UploadFile/mahesh/ReadWriteXMLTutMellli2111282005041517AM/ReadWriteXMLTutMellli21.aspx
Hope, this will help you.
Thanks.
Posted May 20, 2009, 3:32 AM EDT
thanks for your response
but, I will create xml file from a list of string and I must respect this format
<
MarkUp name="string1">Cdata1]]>MarkUp><
MarkUp name="string2">Cdata1]]>MarkUp><
MarkUp name="string2">Cdata1]]>MarkUp><
MarkUp name="string2">Cdata1]]>MarkUp><
MarkUp name="string2">Cdata1]]>MarkUp>my question : how to add attribut and CDATA section in xml file already existing
thanks