User1938476581 posted
Hi,
You can try using Xmltextwriter class with WriteStartElement and WriteStartAttribute and other method. And please refer to the following code:
if (ds.Tables[0].Rows.Count > 0)
{
for (int LIntCtr = 0; LIntCtr <= ds.Tables[0].Rows.Count - 1; LIntCtr++)
{
writer.WriteStartElement("url");
writer.WriteStartAttribute(" ", "id" " ");
writer.WriteString(ds.Tables[0].Rows[LIntCtr][column].ToString()+ "");
writer.WriteElementString("loc", "http://www.mysite.com/articles/" + ds.Tables[0].Rows[LIntCtr]["title"].ToString()+ "");
writer.WriteElementString("lastmod", String.Format("{0:yyyy-MM-dd}", DateTime.Now));
writer.WriteElementString("changefreq", "daily");
writer.WriteElementString("priority", "1.00");
writer.WriteEndElement();
}
}
writer.WriteEndElement();
writer.Flush();
For more information, please refer to the document:
http://stepcoder.com/Articles/10009/how-to-create-dynamic-sitemap-xml-file-from-database-in-asp-net
#How to Create a XML File Using XmlTextWriter
http://www.mindfiresolutions.com/How-to-Create-a-XML-File-Using-XmlTextWriter-117.php
http://bytes.com/topic/net/answers/625000-how-use-xmlwriter-add-attribute-any-element