Ejemplo n.º 1
0
        private void SubmitEngine(string engine, string sitemapUrl)
        {
            //Check if it is not localhost because search engines returns an error
            if (!sitemapUrl.Contains("http://localhost"))
            {
                string request = string.Concat(engine, SitemapItem.HtmlEncode(sitemapUrl));

                System.Net.HttpWebRequest httpRequest =
                    (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(request);
                try
                {
                    System.Net.WebResponse webResponse = httpRequest.GetResponse();

                    System.Net.HttpWebResponse httpResponse = (System.Net.HttpWebResponse)webResponse;
                    if (httpResponse.StatusCode != System.Net.HttpStatusCode.OK)
                    {
                        Log.Error(string.Format("Cannot submit sitemap to \"{0}\"", engine), this);
                    }
                }
                catch
                {
                    Log.Warn(string.Format("The serachengine \"{0}\" returns an 404 error", request), this);
                }
            }
        }
Ejemplo n.º 2
0
        private XmlDocument BuildSitemapItem(XmlDocument doc, SitemapItem item, Site site)
        {
            XmlNode urlsetNode = doc.LastChild;

            XmlNode urlNode = doc.CreateElement("url");

            urlsetNode.AppendChild(urlNode);

            XmlNode locNode = doc.CreateElement("loc");

            urlNode.AppendChild(locNode);
            locNode.AppendChild(doc.CreateTextNode(item.Location));

            XmlNode lastmodNode = doc.CreateElement("lastmod");

            urlNode.AppendChild(lastmodNode);
            lastmodNode.AppendChild(doc.CreateTextNode(item.LastModified));

            if (!string.IsNullOrWhiteSpace(item.ChangeFrequency))
            {
                XmlNode changeFrequencyNode = doc.CreateElement("changefreq");
                urlNode.AppendChild(changeFrequencyNode);
                changeFrequencyNode.AppendChild(doc.CreateTextNode(item.ChangeFrequency));
            }

            if (!string.IsNullOrWhiteSpace(item.Priority))
            {
                var priorityNode = doc.CreateElement("priority");
                urlNode.AppendChild(priorityNode);
                priorityNode.AppendChild(doc.CreateTextNode(item.Priority));
            }

            return(doc);
        }