Guest User

Untitled

a guest
Apr 8th, 2019
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.73 KB | None | 0 0
  1. <?php header("Content-Type: application/rss+xml; charset=UTF-8"); setlocale(LC_TIME,'Italian_Italy.UTF-8','Italian_Italy.1250','it'); ?><?php echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" ?>
  2. <rss version="2.0">
  3.     <channel>
  4.         <title>Turbolab Italia</title>
  5.         <link>https://turbolab.it</link>
  6.         <description>Conversione RSS per Amazon Alexa</description>
  7.         <language>it-IT</language>
  8.         <copyright>Copyright 2019, TurboLab.it</copyright>
  9.         <?php
  10.             $xmldom = new DOMDocument();
  11.             $xmldom->load("https://turbolab.it/feed"); 
  12.             $items = $xmldom->getElementsByTagName("item");
  13.             for($i=0; $i<5 && $i<$items->length-1; $i++) {
  14.                 $title = $items->item($i)->getElementsByTagName("title")->item(0)->childNodes->item(0)->nodeValue;
  15.                 $title = preg_replace('/[^A-Za-z0-9 \’\'\,\.àèìòùé]/', '', $title);
  16.                 $link = $items->item($i)->getElementsByTagName("link")->item(0)->childNodes->item(0)->nodeValue;
  17.                 $description = $items->item($i)->getElementsByTagName("description")->item(0)->textContent;
  18.                 $description = preg_match('/<p>(.*?)<\/p>/',$description,$paragrafi);
  19.                 $description = $paragrafi[1];
  20.                 $description = preg_replace('/[^A-Za-z0-9 \’\'\,\.àèìòùé]/', '', $description);
  21.                 $pubDate = $items->item($i)->getElementsByTagName("pubDate")->item(0)->childNodes->item(0)->nodeValue;
  22.                 $guid = $items->item($i)->getElementsByTagName("guid")->item(0)->childNodes->item(0)->nodeValue;
  23.         ?>
  24.             <item>
  25.                 <title><?php echo $title; ?></title>
  26.                 <link><?php echo $link; ?></link>
  27.                 <description><?php echo $description; ?></description>
  28.                 <pubDate><?php echo $pubDate; ?></pubDate>
  29.                 <guid><?php echo $guid; ?></guid>
  30.             </item>
  31.         <?php } ?>
  32.  
  33.     </channel>
  34. </rss>
Add Comment
Please, Sign In to add comment