Yngvarr

Generation

generate functionSat, 07 Jan 2023

return xml gz archive

function generate_sitemap() { //generate sitemap $sitemap = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" />'); //add some urls $url = $sitemap->addChild('url'); $url->addChild('loc', 'http://www.url.com'); $url->addChild('lastmod', date('Y-m-d')); $url->addChild('changefreq', 'daily'); $url->addChild('priority', '1.0'); //save to disk $fp = fopen(__DIR__.'/sitemap.xml', 'wb'); fwrite($fp, $sitemap->asXML()); fclose($fp); //return sitemap as a string return $sitemap->asXML(); } ``

Questions about programming?Chat with your personal AI assistant