public function createDocument(\DOMDocument $dom, $root, $url, $priority, $date = '', $daily = "0.8")
{
// if (!empty($title)) {
// 建立根下子节点track
$track = $dom->createElement("url");
$root->appendChild($track);
// 建立track节点下元素
$loc = $dom->createElement("loc");
$track->appendChild($loc);
$lastmod = $dom->createElement("lastmod");
$track->appendChild($lastmod);
$changefreq = $dom->createElement("changefreq");
$track->appendChild($changefreq);
$priority = $dom->createElement("priority");
$track->appendChild($priority);
$urlText = $dom->createTextNode($url);
$loc->appendChild($urlText);
if (empty($date)) {
$date = date("Y-m-d", time());
}
$textDate = $dom->createTextNode($date);
$lastmod->appendChild($textDate);
$changefreqText = $dom->createTextNode($priority);
$changefreq->appendChild($changefreqText);
$text = $dom->createTextNode($daily);
$priority->appendChild($text);
}
使用PHP如何生成百度XML?
于 2023-02-24 11:20:49 首次发布