Thanks for your response. I changed in the above coding. Now it is working fine.
Response.Clear();
Response.ContentType = "text/xml";
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(Server.MapPath("XML/URL2.xml"), settings))
{
writer.WriteStartDocument();
writer.WriteStartElement("urlset");
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["SqlConn"].ToString());
string str = "Select * from WebsiteURL where IsActive=0";
SqlDataAdapter da = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
for (i = 0; i <= ds.Tables[0].Rows.Count - 1; )
{
writer.WriteStartElement("url");
writer.WriteElementString("loc", ds.Tables[0].Rows[i]["EnglishPageURL"].ToString());
writer.WriteElementString("lastmod", DateTime.Now.ToShortDateString());
writer.WriteElementString("changefreq", "daily");
writer.WriteElementString("priority", "0.9");
writer.WriteEndElement();
i = i + 1;
}
}
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
}