I'm working in creating a simple script to generate Google site maps dynamically but i have a small issue,when i viewed the normal site maps for Google i found those lines inside the main root element which called urlset
:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
xmlns="http://www.sitemaps.org/schemas/sitemap/0.9
I'm creating the site maps through DOMdocument
PHP and i need to know how to add this header or codes to my main child ?
this is my code :
$doc = new DOMDocument('1.0', 'UTF-8');
$map = $doc->createElement('urlset');
$map = $doc->appendChild($map);
$url = $map->appendChild($doc->createElement('url'));
$url = $map->appendChild($doc->appendChild($url));
$url->appendChild($doc->createElement('loc',$link));
$url->appendChild($doc->createElement('lastmod',$date));
$url->appendChild($doc->createElement('priority',$priority));
$doc->save('sitemap.xml');
The code just work fine and generate the XML file with no problems but when i tried to check the validity of the site map by validating it, it gives this error
Element 'urlset': No matching global declaration available for the validation root OR Can not find declaration of element 'urlset'.
which caused because of the missing header i think .