I am creating a web application using php. I want to create a sitemap for my application. I dont know how to create that xml file and how to include in php. And also I want to know that, is it possible to check that in my localhost before upload into my hosting server? I want a simple example code to create the sitemap.xml file and how to link that in php page? Please, does any one can help me?

Re: Create a sitemap.xml file for a site and include in the php file 80 80

If your pages are stored in the database, then you can generate your sitemap easily from a query. It depends on how your website is built.

Re: Create a sitemap.xml file for a site and include in the php file 80 80
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc>http://mysite.com/</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Weekly</changefreq>
        <priority>0.9</priority>
    </url>
    <url>
        <loc>http://mysite.com/about.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>http://mysite.com/something.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Daily</changefreq>
        <priority>0.7</priority>
    </url>
    <url>
        <loc>http://mysite.com/contact.php</loc>
        <lastmod>2012-09-16</lastmod>
        <changefreq>Monthly</changefreq>
        <priority>0.6</priority>
    </url>
</urlset>

not sure what youre trying to test locally but your sitemap don't mean much on a local server so you can open it and check for errors but thats about it. you can hardcode the sitemap in your php or convert the sitemap using regex but thats a pain in the ass. I think there are frameworks that can handle that but your better of hardcoding it in an unordered list

Re: Create a sitemap.xml file for a site and include in the php file 80 80

thank you! I got the required result

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.