Question : an example from w3schools

hello:

i'm using the example from this link: http://www.w3schools.com/php/php_ajax_rss_reader.asp

the follwing is my customzied code. but i got an error in Firefox
Warning: DOMDocument::load() [function.load]: Document is empty in http://rss.msnbc.msn.com/id/3032091/device/rss/rss.xml line: 1

I guess which is because i don't call the javascipt: getrss.js in the link: http://www.w3schools.com/php/php_ajax_rss_reader.asp

i am new to ajax. please help check how to modify the code.

thanks a million!!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
load($xml);
//get and output "" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=5; $i++)
 {
 $item_title=$x->item($i)->getElementsByTagName('title')
 ->item(0)->childNodes->item(0)->nodeValue;
 $item_link=$x->item($i)->getElementsByTagName('link')
 ->item(0)->childNodes->item(0)->nodeValue;
 $item_date=$x->item($i)->getElementsByTagName('pubDate')
 ->item(0)->childNodes->item(0)->nodeValue; 
 
 if (strlen($item_date) == 29)
	$item_date= substr($item_date, 0, 16);
				
elseif (strlen($item_date) == 28)
	$item_date= substr($item_date, 0, 15);
 
 echo "\n".$item_date."
\n"; echo "

\n"; echo "".$item_title."

\n"; } ?>
Open in New Window Select All

Answer : an example from w3schools

Hi! Your PHP script is working for me (together with the HTML and JS from w3schools).

Your error is not being caused due to your JS script not being called getrss.js - otherwise you wouldn't get this PHP error.

It seems like the DOMDocument class is having trouble parsing the RSS feed on MSN.com.

Have you tried using a different feed? Try the Google news feed and see if that works ...
Random Solutions  
 
programming4us programming4us