-
Notifications
You must be signed in to change notification settings - Fork 0
/
SiteMapHelper
27 lines (22 loc) · 1.19 KB
/
SiteMapHelper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
internal static class SiteMapHelper
{
public static string Path = HttpContext.Current.Server.MapPath("~/sitemap.xml");
public static void AddSiteMapEntry(SiteMapModel siteMapModel)
{
string postUrl = "https://www.balajibirajdar.com/" + siteMapModel.PageUrl;
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(HttpContext.Current.Server.MapPath("~/sitemap.xml"));
XmlElement urlNode = xmlDocument.CreateElement("url");
XmlElement locNode = xmlDocument.CreateElement("loc");
locNode.InnerText = postUrl;
urlNode.AppendChild(locNode);
XmlElement lastModNode = xmlDocument.CreateElement("lastmod");
lastModNode.InnerText = DateTime.Now.ToString("yyyy-mm-ddThh:mm:ss:zzz");
urlNode.AppendChild(lastModNode);
XmlElement priorityNode = xmlDocument.CreateElement("priority");
priorityNode.InnerText = "0.80";
urlNode.AppendChild(priorityNode);
xmlDocument.DocumentElement.AppendChild(urlNode);
xmlDocument.Save(HttpContext.Current.Server.MapPath("~/sitemap.xml"));
}
}