/**************************************************************************/ public void WriteSitemapXml(string NewPath) { string StartUriHostAndPort = null; string XmlSitemapSerialized = null; XmlDocument SitemapXml; StringWriter SitemapXmlStringWriter; XmlTextWriter SitemapXmlTextWriter; try { StartUriHostAndPort = this.DocCollection.GetJobMaster().GetStartUriHostAndPort(); if (StartUriHostAndPort != null) { SitemapXml = this.GenerateXmlSitemap(Host: StartUriHostAndPort); SitemapXmlStringWriter = new StringWriter(); SitemapXmlTextWriter = new XmlTextWriter(SitemapXmlStringWriter); SitemapXml.WriteTo(SitemapXmlTextWriter); XmlSitemapSerialized = SitemapXmlStringWriter.ToString(); File.WriteAllText(NewPath, XmlSitemapSerialized, new System.Text.UTF8Encoding(false)); } } catch (Exception ex) { this.DebugMsg(string.Format("WriteSitemapXml: {0}", ex.Message)); if (File.Exists(NewPath)) { File.Delete(NewPath); } throw new MacroscopeSitemapException("An error occurred whilst attempting to save the Sitemap XML file."); } }
public SitemapXml GetSiteMap() { var pages = GetSiteMapPages() .Select(page => new SiteMapXmlItem { Location = page.UrlAbsolute(), ChangeFrequency = page.GetChangeFrequency(), Priority = page.SitemapPriority, LastModified = page.UpdateDate }); var siteMap = new SitemapXml { Items = pages.ToList() }; return(siteMap); }
/**************************************************************************/ public void WriteSitemapXml(string NewPath) { string StartHost; string XmlSitemapSerialized; XmlDocument SitemapXml; StringWriter SitemapXmlStringWriter; XmlTextWriter SitemapXmlTextWriter; StartHost = this.DocCollection.GetDocument( Url: this.DocCollection.GetJobMaster().GetStartUrl() ).GetHostAndPort(); XmlSitemapSerialized = null; SitemapXml = this.GenerateXmlSitemap(Host: StartHost); SitemapXmlStringWriter = new StringWriter(); SitemapXmlTextWriter = new XmlTextWriter(SitemapXmlStringWriter); SitemapXml.WriteTo(SitemapXmlTextWriter); XmlSitemapSerialized = SitemapXmlStringWriter.ToString(); File.WriteAllText(NewPath, XmlSitemapSerialized, new System.Text.UTF8Encoding(false)); }