i have the following code, but i want the proper sitemap standard.
my code
$xml = new DomDocument('1.0', 'utf-8');
$xml->formatOutput = true;
$products= $xml->createElement('url');
$product = $xml->createElement('url');
$xml->appendChild($products);
$products->appendChild($product);
$product->appendChild(new DomAttr('loc', '123'));
$xml->save("data.xml");
but the output of the stated code is lile:
<?xml version="1.0" encoding="utf-8"?>
<url>
<url loc="123"/>
</url>
But i want the following standard…
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/</loc>
<lastmod>2012-08-11T04:08:53+01:00</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
</urlset>
please help me in this regard.
You have already proven to create an XML document by your syntax – just recreate the standard template.
For example’s sake, I will pretend your website info is stored in array such as:
Then sticking back to your example:
The rest is up to you.