Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Ajax XML parsing problem.

xml innerHTML ajax

  • Please log in to reply
No replies to this topic

#1 danny4444


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 16 June 2010 - 03:08 AM

Hi, im a new user, and fairly new to ajax.

I'm trying to create a blog that uses RSS. The problem is that google chrome displays the results from the rss.php script, yet Internet Explorer does not. Any help would be greatly appreciated.

Here are the functions i am using for the communication to the script and the parsing of the XML returned. (as you can see I have gone backwards to just trying to get the title tag of the XML tags to display... still nothing in IE).

var loaded = 3;

function ajaxrequest2()

    var request2 = new Ajax.Request
            { method: 'get',
              onComplete: rssReturned }

function rssReturned (xmlHTTP2)
    var itemsArray = xmlHTTP2.responseXML.getElementsByTagName("item");
    var html="";
	var ilength = itemsArray.length;
	for(var count=0; count<ilength&&count<loaded; count++)
		var title = itemsArray[count].getElementsByTagName("title")[0].firstChild.nodeValue;
                html=html+"<div class='rsstop'>"+title+"</div>";


	document.getElementById("blogcontent").innerHTML = html;

Here is the RSS.php Script:


header("Content-type: application/rss+xml");


$query = "SELECT * FROM `stories` ORDER BY `id` DESC";


echo "<rss version='2.0' xmlns:atom='http://www.w3.org/2005/Atom'>";
echo "<channel>";
echo "<title>Mightydrive</title>";
echo "<link>http://mightydrive.co.uk/rss.php</link>";
echo "<description>Latest goings on with Mightydrive</description>";

echo "<atom:link href='http://localhost/mightydrive/rss.php' rel='self' type='application/rss+xml' />";

    echo "<item>";
    echo "<title>".$row['title']."</title>";
	echo "<category>".$row['category']."</category>";
    echo "<link>http://mightydrive.co.uk/fullstory.php?id=".$row['id']."</link>";
    echo "<description>".$row['description']."</description>";
	echo "<author>".$row['author']."</author>";

    // This line converts a database date format 
    // (e.g. 2006-09-22 12:30:00) to an RSS date
    // (e.g. Fri, 22 Sep 2006 12:30:00 GMT)

    $rssdate = date("D, j M Y H:i:s", strtotime($row['pubDate'])). " GMT";

    echo "<pubDate>".$rssdate."</pubDate>";
	echo "<guid>http://mightydrive.co.uk/blog.php?id=".$row['id']."</guid>";
    echo "</item>";

echo "</channel>";
echo "</rss>";

Sorry if i've missed anything out... any help would be greatly appreciated.


  • 0

Also tagged with one or more of these keywords: xml, innerHTML, ajax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download