I want to fetch data from XMl File (BBC News RSS Feeds) and show it in my html page ... but I have a minor problem.I saved the XML RSS feeds File on my local server and its running fine but when i am trying to fetch the XML data online by placing a url its not working ... Thank you
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
var url = "bbc.xml";
xmlhttp.open("GET",url,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table><tr><th>Artist</th><th>Title</th></tr>");
var x=xmlDoc.getElementsByTagName("item");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
the upper code is running Fine but when i placed URL For XML File to fetch data ... the page is not showing any data like this
var url = "http://ift.tt/1yCjxXz";
xmlhttp.open("GET",url,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
What i need to do ... help me
No comments:
Post a Comment