Here's the result, place this in the same directory as index.php and call it sitemap.php.
This script will generate a Google compatible sitemap for the whole blog.
There are some limitations:
- Will not work if there are more than 50,000 entries in the blog
- Categories are not included
- Each blog entry last updated date is the blog entry date, not the date of the last comment for the entry
Edit: the original version of this code didn't take the time offset into account, I've updated it now to use the offset. Without the offset, the URLs are not created correctly sometimes.
Edit 2: changed the locations to use permalinks instead of the pretty URLs because I've noticed a large number of the URLs were not being generated correctly due to the time offsets.
Edit 3: the escape slashes got stripped out in the original code, I've changed the code so escapes are not required.