SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    844
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Trying to make a dynamic XML Sitemap for Google

    When I run this script I made, it produces all the data (URLs, last modified date, etc) but it does not look like a standard XML feed. Is there something I've overlooked? I want to make a dynamic Sitemap so that Google always has the full list of all my dynamic content.

    Thanks!!


    PHP Code:
    <?php

    include 'db.inc.php'

    print (
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    print (
    "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">");


    $getTestimonials "SELECT tID, date from testimonies where approved ='Yes' order by date desc limit 15";

    $result mysql_query ($getTestimonials) OR die(mysql_error());

    if (
    $row mysql_fetch_array($result)) {

    print (
    "<urlset>\n");

    do {

    $tID        $row["tID"];
    $date        $row["date"];    


    $date date("D, d M Y H:i:s \G\M\T");


    print (
    "\n\n<url>\n");
    print (
    "<loc>http://www.oil-testimonials.com/essential-oils/$tID</loc>\n");
    print (
    "<lastmod>$date</lastmod>\n");
    print (
    "<changefreq>yearly</changefreq>\n");
    print (
    "</url>\n");

    } while(
    $row mysql_fetch_array($result));

    print (
    "</urlset>\n");

    } else {print 
    "Sorry, no testimonials were found!";}


    ?>
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,446
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)
    I'm not sure what you mean by it doesn't look like a standard XML feed. Can you post a sample of it?

    You should probably have it send Content-type: text/xml headers if it isn't already. Otherwise it will most likely default to text.

    And if you want indentation you could add some "\t"s here and there.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •