Donnie Thomas
Donnie Thomas

Reputation: 4038

Create Google compliant dynamic XML sitemap

I want to create a dynamic (fetching data from the database) XML sitemap which I can submit to Google webmaster tools.

Surprisingly, I couldn't find any recent controls/code online to do this. The most recent code I found was this http://weblogs.asp.net/bleroy/archive/2005/12/02/432188.aspx which is for ASP.Net 2.0. I don't mind using this, but I suspect it's outdated.

Can somebody please point me in the direction of code which accomplishes this?

Upvotes: 1

Views: 9311

Answers (2)

Carlos Muñoz
Carlos Muñoz

Reputation: 17804

Actually i just done it recently using LinqToXMl

How to generate xsi:schemalocation attribute correctly when generating a dynamic sitemap.xml with LINQ to XML?

Actually the string that is returned by that code is written directly to the Response object. I use a .ashx HttpHandler to deliver the content as XML and using Routing to serve it under the name of sitemap.xml. Also you should put it on your robots.txt file

Upvotes: 0

Garett
Garett

Reputation: 16818

A couple of options include:

The ASP.Net SiteMap infrastructure. It allows you to write a custom sitemap provider like this one, which uses Micosoft Access, to generate a sitemap.

You can also find a very simple sitemap generator project on this site.

Another option (and fun learning experience) is to write your own by just looking at the sitemap protocol, and using Linq To SQL along with Linq To Xml to generate the format. Here is an example uses Linq To SQL and Linq To XML to generate XML.

Finally, Google also accepts RSS/Atom feeds, so you could generate one of those instead. If you go this route then you can make use of the SyndicationFeed class. There are also a couple open source options available.

Upvotes: 2

Related Questions