") or die("Error: Cannot create object"); $news = $xml->xpath('//item'); //#### Create Table #### echo ''; //#### Foreach news article do #### foreach($news as $a) { //#### Title of news #### echo ''; //#### Date of news #### echo ''; //#### Picture in news #### echo ''; //#### Remove HTML tags from description #### $desc = strip_tags($a->description); //#### Open function to limit text to 250 chars #### echo ''; //#### Some empty rows #### echo ''; echo ''; } echo "
' . $a->title . '
' . $a->pubDate . '
' . truncate($desc) . '


"; //#### Function to limit text to 250 chars #### //#### https://stackoverflow.com/questions/3161816/get-first-n-characters-of-a-string #### function truncate($string,$length=250,$append="…") { $string = trim($string); if(strlen($string) > $length) { $string = wordwrap($string, $length); $string = explode("\n", $string, 2); $string = $string[0] . $append; } return $string; } ?>