'); $xml->addAttribute("version", "2.0"); $channel = $xml->addChild("channel"); $channel->addChild("title", "Your feed title"); $channel->addChild("link", "Your website's uri"); $channel->addChild("description", "Describe your feed"); $channel->addChild("language", "en-us"); if(isset($a_item[0])) { foreach ($a_item as $entry) { $item = $channel->addChild("item"); $item->addChild("title", $entry['text']); $item->addChild("link", $entry['href']); $item->addChild("description", $entry['text']); } } echo $xml->asXML(); } function readHTML($url){ // inisialisasi CURL $data = curl_init(); // setting CURL curl_setopt($data, CURLOPT_RETURNTRANSFER, 1); curl_setopt($data, CURLOPT_URL, $url); // menjalankan CURL untuk membaca isi file $hasil = curl_exec($data); curl_close($data); return $hasil; } $url_target = "http://www.pertanian.go.id/home/?show=news&act=view_all&cat=5"; $html_code = readHTML($url_target); //echo $html_code; $links = array(); $dom = new DOMDocument; libxml_use_internal_errors(true); $content_top = explode("
", $html_code); if(isset($content_top[1])) { for($i=1;$i", $content_top[$i]); $dom->loadHTML($a_content[0]); $arr = $dom->getElementsByTagName("a"); foreach($arr as $item) { $href = $item->getAttribute("href"); $text = trim(preg_replace("/[\r\n]+/", " ", $item->nodeValue)); $links[] = [ 'href' => $href, 'text' => $text ]; } } libxml_clear_errors(); } renderRSS($links); ?>