prepareQuery(); $table = $config->sql_tablename_publish_de(); //create your XML document, using the namespaces $urlset = new SimpleXMLElement(''); $stmt1 = $pdo1->prepare("SELECT p_headline,p_shortcode FROM $table WHERE id>=0 ORDER BY id DESC LIMIT 49995;"); $stmt1->execute(); while($rows1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { $row_count++; $all_row_count++; $p_headline = $func->clear_string($rows1["p_title"]); $p_shortcode = $rows1["p_shortcode"]; $lastmod = date('c',time()); $rand_vor = rand(6, 9); $rand_nach = rand(1, 9); $makeArticleLink = $func->makeArticleLink($p_shortcode); $linkingcode = "https://blog.onetopp.com/$makeArticleLink"; if ( strlen($makeArticleLink) > 42 ){ //add the page URL to the XML urlset $url = $urlset->addChild('url'); $url->addChild('loc', $linkingcode ); $url->addChild('lastmod', $lastmod ); $url->addChild('changefreq', 'monthly'); //weekly etc. $url->addChild('priority', "0.$rand_vor".$rand_nach); $image = $url->addChild('image:image', null, 'http://www.google.com/schemas/sitemap-image/1.1'); $image->addChild('image:loc',"https://blog.onetopp.com/i.php?s=$p_shortcode", 'http://www.google.com/schemas/sitemap-image/1.1'); $image->addChild('image:caption',$p_headline, 'http://www.google.com/schemas/sitemap-image/1.1'); $image->addChild('image:title',$p_headline, 'http://www.google.com/schemas/sitemap-image/1.1'); } }; //add whitespaces to xml output (optional, of course) $dom = new DomDocument(); $dom->loadXML($urlset->asXML()); $dom->formatOutput = true; //output xml echo $dom->saveXML(); exit(0); ?>