MikroSight.com

MikroSight.com

| Home | NPA/NPX |

Google
Web
MikroSight

Site Map Listing Tutorial

For site maps on my sites, I always wanted a listing that just read my site from the server and made a site map "on the fly". That saves me having to maintain it - it's automagic.

That's not quite what I ended up with though. Because of Google and their service for webmasters that allows me to submit an XML file to them, I needed a way to generate that file and keep it available on my site.

In my first Site Map Tutorial, I detailed how I used a file system tree traversal routine to generate a standard Google Sitemap.xml file using PHP. This tutorial deals with the idea of using that xml file to create my site map.

It's a simple process really - not much to explain. I started with an RSS parser that I got from an article by Kevin Yank on SitePoint.com. In his article, Kevin shows how to use the standard PHP function xml_parser_create. I note both references here for those that want to delve further into how all this works.

Starting with Kevin's basic script, I made modifications to the code to read the Google sitemap.xml format. My first attempt merely listed the page URL as an <a> tag so it could be clicked to access the page. You can see an example of that here and the code I use is shown on page 2.

Next week, I'll detail further changes to this script to show how I pull the <title> tag from each page, do some basic formatting on it and use that to create my site map listing.

Feel free to contact me with any questions about this routine.

Site Map Listing Tutorial - Page 2