internal void GetGoogleSiteMapPageEntry(XmlWriter writer, SitePage sitePage)
        {
            writer.WriteStartElement("url");
            byte[] locBytes;
            locBytes = Encoding.UTF8.GetBytes(sitePage.Loc);
            writer.WriteElementString("loc", Encoding.UTF8.GetString(locBytes));

            locBytes = Encoding.UTF8.GetBytes(sitePage.Title);
            writer.WriteElementString("title", Encoding.UTF8.GetString(locBytes));

            writer.WriteElementString("lastmod", SitePage.FormatISODate(sitePage.LastMod));
            writer.WriteElementString("changefreq", sitePage.ChangeFreq.ToString());
            writer.WriteElementString( "priority", sitePage.Priority.ToString( "N1",new System.Globalization.CultureInfo( "en-US" ) ) );
            writer.WriteEndElement();
        }
        public string GetGoogleSiteMap(string siteURL)
        {
            //strip any resource off the end of the URL to get the base URL
            SetBaseURL(siteURL);
            //instantiate the XML Text Writer for writing the SiteMap document
            StringWriter stringWriter = new StringWriter();
            XmlTextWriter writer = new XmlTextWriter(stringWriter);
            //write out the header
            WriteSiteMapHeader(writer);

            Site site;
            string siteUrl = UrlHelper.GetSiteUrl();
            SiteAlias currentSiteAlias = this._siteService.GetSiteAliasByUrl(siteUrl);
            if (currentSiteAlias != null)
                site = currentSiteAlias.Site;
            else
                site = _siteService.GetSiteBySiteUrl(siteUrl);

            if (site != null)
            {
                IList nodes = _nodeService.GetNodesBySite(site);

                //for each page, write out the XML
                int urlCount = 0;
                // foreach( SitePage sitePage in sitePages )
                foreach (Node node in nodes)
                {
                    if (!node.IsExternalLink
                        && node.AnonymousViewAllowed
                        && node.ShowInNavigation)
                    {
                        SitePage sitePage = new SitePage();
                        sitePage.ChangeFreq = DefaultPageUpdateFrequency;
                        sitePage.LastMod = node.UpdateTimestamp;
                        sitePage.Loc = UrlHelper.GetSiteUrl() + UrlHelper.GetUrlFromNode(node);
                        sitePage.Priority = DefaultPagePriority;
                        sitePage.Title = node.Title;

                        GetGoogleSiteMapPageEntry(writer, sitePage);
                        urlCount++;
                        if (urlCount > 10000)
                        {
                            WriteURLCountExceeded(writer);
                            break;
                        }
                    }
                }
                //Need to add 'Status' to Node object for the original code below to work
                //foreach (Node node in nodes)
                //{
                //    if (node.Status == (int)NodeStatus.Online
                //        && !node.IsExternalLink
                //        && node.AnonymousViewAllowed
                //        && node.ShowInNavigation)
                //    {
                //        SitePage sitePage = new SitePage();
                //        sitePage.ChangeFreq = DefaultPageUpdateFrequency;
                //        sitePage.LastMod = node.UpdateTimestamp;
                //        sitePage.Loc = UrlHelper.GetSiteUrl() + UrlHelper.GetUrlFromNode(node);
                //        sitePage.Priority = DefaultPagePriority;
                //        sitePage.Title = node.Title;

                //        GetGoogleSiteMapPageEntry(writer, sitePage);
                //        urlCount++;
                //        if (urlCount > 10000)
                //        {
                //            WriteURLCountExceeded(writer);
                //            break;
                //        }
                //    }
                //}
            }

            WriteSiteMapFooter(writer);
            writer.Close();
            return stringWriter.ToString();
        }