使用PHP如何生成百度XML?

 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);
    }


版权声明:本文为u010670796原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。