I develop a XML sitemap generator, everything works well but I have problems with image node, this should be image:image, normal is my code so:
$xml->addChild('lastmod', date('Y-m-d'));
I try to add my image node so:
$xml->addChild('image:image', '');
If I create sitemap then I don't see but
How can I fix it to see node like image:image?
Full code:
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd"></urlset>');
$i = 1;
foreach ($results as $result) :
if ($i < 17) :
$map = $xml->addChild('url');
$map->addChild('loc', pageURL());
$map->addChild('lastmod', date('Y-m-d'));
$map->addChild('image:image', true);
endif;
$i++;
endforeach;
file_put_contents('sitemap.xml',$xml->saveXML());
echo '<pre><b>Sitemap generated</b></pre>';
NOTE: ignore foreach, it works perfect.
My prevous source:
PHP library for parsing XML with a colons in tag names?