View Single Post
Old 11-30-2008, 11:05 PM   PM User | #5
rizzo89
New Coder

 
Join Date: Nov 2008
Posts: 10
Thanks: 1
Thanked 0 Times in 0 Posts
rizzo89 is an unknown quantity at this point
I have found a solution for my application.

Now I just need an auto-sitemap generator so that it is updated for search engines and my site without me doing anything....??

sitemap.php
Code:
<html>....
<?php

   $xslDoc = new DOMDocument();
   $xslDoc->load("stylesheets/sitemap.xsl");

   $xmlDoc = new DOMDocument();
   $xmlDoc->load("sitemap.xml");

   $proc = new XSLTProcessor();
   $proc->importStylesheet($xslDoc);
   echo $proc->transformToXML($xmlDoc);
?>
</html>
sitemap.xsl
Code:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">

    <table class="sitemap">
    <tr>
      <th align="left">URLs</th>
      <th align="left">Last Modified</th>
    </tr>
    
	<xsl:for-each select="urlset/url">
    <tr>
	<td>	
	<xsl:element name="a">
	<xsl:attribute name="href">
	<xsl:value-of select="loc"/>
	</xsl:attribute>
	<xsl:value-of select="loc"/>
	        </xsl:element>
	</td>
	<td><xsl:value-of select="lastmod"/></td>
    </tr>
    
	</xsl:for-each>
    </table>

</xsl:template>
</xsl:stylesheet>
sitemap.xml
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<urlset>
	<url>
		<loc>http://www.asdf.com/</loc>
		<lastmod>2008-10-01</lastmod>
</url>
</urlset>
rizzo89 is offline   Reply With Quote