0

не могу в ХМЛ файлу добавить урл не получается вот сам код заранее спасибо

 $url_music = "http://" . $_SERVER["HTTP_HOST"] . "/index.php?a=track&id=".$row['id'];
$sql =  mysqli_query($db,"INSERT INTO `test` (`name`)VALUES('$url_music')");
$date = $row['time'];
$date = str_replace(' ', 'T', $date);
$xml = simplexml_load_file($_SERVER["DOCUMENT_ROOT"]."/sitemap.xml");
$sxe = new SimpleXMLElement($xml->asXML());
$newItem = $sxe->addChild("url");
$newItem->addChild("loc", "http://my-beybi.ru/index.php?a=track&id=30&name=art-avetisyan-anirakan-wwwergerru-2019mp3");

$newItem->addChild("lastmod", $date.'+03:00');
$newItem->addChild("changefreq", 'weekly');

$sxe->asXML($_SERVER["DOCUMENT_ROOT"]."/sitemap.xml");

1 ответ 1

0

HTML-символы нужно экранировать

$newItem->addChild(
    'loc',
    htmlspecialchars('http://my-beybi.ru/index.php?a=track&id=30&name=art-avetisyan-anirakan-wwwergerru-2019mp3')
);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.