By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,402 Members | 1,695 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,402 IT Pros & Developers. It's quick & easy.

Google SiteMap

P: n/a
Hello,

I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's
sitemap file.

I am posting the formats of both files.

1. How can I do the conversion?

2. And can I use an .ashx Asp.Net file that when the .ashx file is
called the Google XML file is generated?

Thank You,
Miguel

GOOGLE SiteMap

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/example.aspx</loc>
< lastmod>2005-01-01</lastmod>
< changefreq>daily</changefreq>
< priority>0.8</priority>
</url>
</urlset>

ASP.NET 2.0 Site Map

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/example.aspx"
changefreq = "daily"
lastmod = "2005-01-01"
description = "My example page and its contents"
priority = "0.8"
title = "Example page" />
</siteMapNode>
</siteMap>

Note: description and title should be droped when converting from
Asp.Net to Google sitemap.

Oct 8 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Have you seen this?

http://www.gotdotnet.com/codegallery...b-e486dd598604

"This project builds Google (tm) compatible sitemap files from ASP.NET
SiteMaps. A simple control that exposes ASP.NET SiteMaps as HTML to help
other search engines index the site is also provided."
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's
sitemap file.

I am posting the formats of both files.

1. How can I do the conversion?

2. And can I use an .ashx Asp.Net file that when the .ashx file is
called the Google XML file is generated?

Thank You,
Miguel

GOOGLE SiteMap

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/example.aspx</loc>
< lastmod>2005-01-01</lastmod>
< changefreq>daily</changefreq>
< priority>0.8</priority>
</url>
</urlset>

ASP.NET 2.0 Site Map

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/example.aspx"
changefreq = "daily"
lastmod = "2005-01-01"
description = "My example page and its contents"
priority = "0.8"
title = "Example page" />
</siteMapNode>
</siteMap>

Note: description and title should be droped when converting from
Asp.Net to Google sitemap.

Oct 8 '06 #2

P: n/a
Here's a handler that should get you going.

Ken
Microsoft MVP [ASP.NET]

<%@ WebHandler Language="VB" Class="googlesitemap" %>
' googlesitemap.ashx
' Adapted from a C# version in
' ASP.NET 2.0 Unleashed
' http://www.superexpert.com/Books/Asp...d/Default.aspx
' by Ken Cox [MVP - ASP.NET]
Imports System.Web
Imports System.Xml
Imports System.Text
Imports System.IO

Public Class googlesitemap : Implements IHttpHandler
Private xmlwtr As XmlWriter
Public Sub ProcessRequest _
(ByVal context As HttpContext) _
Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/xml"
Dim settings As XmlWriterSettings = _
New XmlWriterSettings()
settings.Encoding = Encoding.UTF8
settings.Indent = True
xmlwtr = XmlWriter.Create _
(context.Response.OutputStream, settings)
xmlwtr.WriteStartDocument()
xmlwtr.WriteStartElement _
("urlset", "http://www.google.com/schemas/sitemap/0.84")
' Add root node
AddUrl(SiteMap.RootNode)
' Add all other nodes
Dim nodes As SiteMapNodeCollection = _
SiteMap.RootNode.GetAllNodes()
For Each node As SiteMapNode In nodes
AddUrl(node)
Next node

xmlwtr.WriteEndElement()
xmlwtr.WriteEndDocument()
xmlwtr.Flush()
End Sub

Private Sub AddUrl(ByVal node As SiteMapNode)
' Skip empty Urls
If String.IsNullOrEmpty(node.Url) Then
Return
End If
' Skip remote nodes
If node.Url.StartsWith("http", True, Nothing) Then
Return
End If
' Open url tag
xmlwtr.WriteStartElement("url")
' Write location
xmlwtr.WriteStartElement("loc")
xmlwtr.WriteString(GetFullUrl(node.Url))
xmlwtr.WriteEndElement()
' Write last modified
xmlwtr.WriteStartElement("lastmod")
xmlwtr.WriteString(GetLastModified(node.Url))
xmlwtr.WriteEndElement()
' Write changefreq
xmlwtr.WriteStartElement("changefreq")
xmlwtr.WriteString("daily")
xmlwtr.WriteEndElement()
' Write priority
xmlwtr.WriteStartElement("priority")
xmlwtr.WriteString("0.8")
xmlwtr.WriteEndElement()
' Close url tag
xmlwtr.WriteEndElement()
End Sub

Private Function GetFullUrl _
(ByVal url As String) As String
Dim context As HttpContext = HttpContext.Current
Dim server As String = _
context.Request.Url.GetComponents _
(UriComponents.SchemeAndServer, UriFormat.UriEscaped)
Return Combine(server, url)
End Function

Private Function Combine _
(ByVal baseUrl As String, _
ByVal url As String) As String
baseUrl = baseUrl.TrimEnd(New Char() {"/"c})
url = url.TrimStart(New Char() {"/"c})
Return baseUrl & "/" & url
End Function

Private Function GetLastModified _
(ByVal url As String) As String
Dim context As HttpContext = HttpContext.Current
Dim physicalPath As String = _
context.Server.MapPath(url)
Return File.GetLastWriteTimeUtc _
(physicalPath).ToString("s")
End Function

Public ReadOnly Property IsReusable() _
As Boolean Implements IHttpHandler.IsReusable
Get
Return True
End Get
End Property

End Class

"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's
sitemap file.

I am posting the formats of both files.

1. How can I do the conversion?

2. And can I use an .ashx Asp.Net file that when the .ashx file is
called the Google XML file is generated?

Thank You,
Miguel

GOOGLE SiteMap

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/example.aspx</loc>
< lastmod>2005-01-01</lastmod>
< changefreq>daily</changefreq>
< priority>0.8</priority>
</url>
</urlset>

ASP.NET 2.0 Site Map

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/example.aspx"
changefreq = "daily"
lastmod = "2005-01-01"
description = "My example page and its contents"
priority = "0.8"
title = "Example page" />
</siteMapNode>
</siteMap>

Note: description and title should be droped when converting from
Asp.Net to Google sitemap.

Oct 8 '06 #3

P: n/a
re:
I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's sitemap file.
Try the ASP.NET to Google sitemap converter:
http://sourceforge.net/projects/sitemap-asp2goo/

The download link is :
http://prdownloads.sourceforge.net/s...1.zip?download

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's
sitemap file.

I am posting the formats of both files.

1. How can I do the conversion?

2. And can I use an .ashx Asp.Net file that when the .ashx file is
called the Google XML file is generated?

Thank You,
Miguel

GOOGLE SiteMap

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/example.aspx</loc>
< lastmod>2005-01-01</lastmod>
< changefreq>daily</changefreq>
< priority>0.8</priority>
</url>
</urlset>

ASP.NET 2.0 Site Map

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/example.aspx"
changefreq = "daily"
lastmod = "2005-01-01"
description = "My example page and its contents"
priority = "0.8"
title = "Example page" />
</siteMapNode>
</siteMap>

Note: description and title should be droped when converting from
Asp.Net to Google sitemap.

Oct 8 '06 #4

P: n/a
Hi,

I saw the links. However, I am trying to do the following:
Each web project will have only one web site map file for each culture.
Inside each node of the web site map I add a attribute such as:

Google=True
or
Footer=True

This way I will be able to use those values to generate Google XML web
sites maps on the fly with an ashx file or even get nodes from the web
site map in my runtime code to fill the footer.

This way I don't have to mantain many web sitemaps.

This is way I am trying to figure out how to make the XML conversion
with XLST and using conditions to.

Thanks,
Miguel
Juan T. Llibre wrote:
re:
I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's sitemap file.

Try the ASP.NET to Google sitemap converter:
http://sourceforge.net/projects/sitemap-asp2goo/

The download link is :
http://prdownloads.sourceforge.net/s...1.zip?download

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"shapper" <md*****@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello,

I am trying to convert an Asp.Net 2.0 XML sitemap file to a Google's
sitemap file.

I am posting the formats of both files.

1. How can I do the conversion?

2. And can I use an .ashx Asp.Net file that when the .ashx file is
called the Google XML file is generated?

Thank You,
Miguel

GOOGLE SiteMap

<?xml version="1.0" encoding="UTF-8"?>
< urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
< url>
< loc>http://www.mydomain.com/example.aspx</loc>
< lastmod>2005-01-01</lastmod>
< changefreq>daily</changefreq>
< priority>0.8</priority>
</url>
</urlset>

ASP.NET 2.0 Site Map

<?xml version="1.0" encoding="utf-8" ?>
<siteMap
xmlns = "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode>
<siteMapNode
url = "~/example.aspx"
changefreq = "daily"
lastmod = "2005-01-01"
description = "My example page and its contents"
priority = "0.8"
title = "Example page" />
</siteMapNode>
</siteMap>

Note: description and title should be droped when converting from
Asp.Net to Google sitemap.
Oct 9 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.