geskshouDge
New Member
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 \[code\]urlset\[/code\] .\[code\]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\[/code\]I'm creating the site maps through \[code\]DOMdocument\[/code\] PHP and i need to know how to add this header or codes to my main child ?
this is my code :
\[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');\[/code\]the code just work fine and generate the xml file with no problems but when i tried to check the validation of the site map it gives this error\[code\]Element 'urlset': No matching global declaration available for the validation rootORCan not find declaration of element 'urlset'.\[/code\]which caused because of the missing header i think .
this is my code :
\[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');\[/code\]the code just work fine and generate the xml file with no problems but when i tried to check the validation of the site map it gives this error\[code\]Element 'urlset': No matching global declaration available for the validation rootORCan not find declaration of element 'urlset'.\[/code\]which caused because of the missing header i think .