Forum Moderators: coopster

Message Too Old, No Replies

Google Sitemap from Database possible?

         

phprockz

3:56 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



Hello everyone,
I wonder is it possible to generate xml google sitemap from database(mysql) so that my sitemap will be always updated.I have only one table that contain articles i like to generate xml sitemap from that table.Please suggest how it can be done.

mikesmith76

4:53 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



Yeah you can generate xml in php, just need to use

header("Content-type: text/xml");

before outputting any content. So for your problem you would

- run a query to get the desired articles
- output content type and start of xml file
- output xml for each sitemap entry
- output closing xml

you would output the xml using the print command e.g print "<url></url>";

Any questions please ask

phprockz

5:25 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



thanks for ur suggestion....i can generate all records from database.I dont know much abt xml..can u please show one example how to generate xml file using php.

mcavic

6:42 pm on Jun 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's an example of the xml output from my site:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>http://www.domain.com/</loc>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>http://www.domain.com/inventory.php?item=X100</loc>
<changefreq>weekly</changefreq>
<priority>0.6</priority>
</url>
</urlset>

Each page that you want indexed is specified inside a <loc>. Priority is the importance of that page, 1.0 being important, to 0.1 being unimportant.

phprockz

7:40 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



iam able to output xml format in sitemap.php page..i want to know how to generate sitemap.xml from sitemap.php.Can you please.

mcavic

7:51 pm on Jun 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All you have to do is write your php code to output the proper xml. Then you point Google to look at the php page, and it'll see the xml.

phprockz

8:13 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



I dunno how to output php file to xml.How it can be done?

mcavic

8:43 pm on Jun 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



iam able to output xml format in sitemap.php page..

That's all you have to do.

i want to know how to generate sitemap.xml from sitemap.php

You don't need a "sitemap.xml".

phprockz

5:59 am on Jun 16, 2006 (gmt 0)

10+ Year Member



thanks to all.. i successfully done my dynamic sitemap and submitted to google.

Cheers