Thursday, December 4, 2008

How to create and save the XML from a String in Server

Hello ...

Once Again I m here and presenting a post .This Post is really very good when You have to create an Xml file for the flash implemrntaion .You can use this.


protected void CreateXml()
{
XmlDocument empDoc = new XmlDocument();
Response.ContentType = "text/xml";
DataSet ds = getdata("test_GetXML");
XmlDocument UpcomeDoc = new XmlDocument();
Response.ContentType = "text/xml";
if (ds.Tables[0].Rows.Count > 0)
{
try
{
////Load the XML from a String
empDoc.LoadXml("" +
"" +
"First Name" +
"Last Name" +
"
City" +
// "WA99999" +
"
");
////Save the XML data onto a file
empDoc.Save(MapPath("EmployeesNew.xml"));
Response.Write(empDoc.InnerXml);
}
catch (XmlException xmlEx)
{
Response.Write("XmlException: " + xmlEx.Message);
}
catch (Exception ex)
{
Response.Write("Exception: " + ex.Message);
}
}
}


Thax....
Sanjeev Kumar
HelpOnDesk Team

No comments: