test1

$url = 'http://free.supremerssnews.com/yahoo_iran.xml';
$text = file_get_contents($url);
$text = iconv('UTF-8', 'UTF-8//IGNORE', $text);
$dom = new DOMDocument();
$dom->loadXML($text);
$items = $dom->getElementsByTagName(‘item’);
$data = array();
foreach ($items as $item) {
$data[] = array(
‘title’ => $item->getElementsByTagName(‘title’)->item(0)->textContent,
‘description’ => strip_tags($item->getElementsByTagName(‘description’)->item(0)->textContent),
‘date’ => (($date = $item->getElementsByTagName(‘pubDate’)->item(0)) ? $date->textContent : ”)
);
}
?>



Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>