I am parsing an RSS feed using PHP and JavaScript. First I created a proxy with PHP to get the RSS feed. Then get individual data from this RSS feed using JavaScript. My problem is with JavaScript. I can get the whole JavaScript document if I use it console.log(rssData);without errors. If I try to get the individual elements in this document, say, for example <title>, <description>or <pubDate>using rssData.getElementsByName("title");, it displays an error message "Nekopat TypeError: Object .... does not getElementsByName Method" So, my question is: how to get the items in RSS- channel?
Javascript (updated)
function httpGet(theUrl) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", theUrl, false);
xmlHttp.send(null);
return xmlHttp.responseXML;
}
var rssData = httpGet('http://website.com/rss.php');
var allTitles = rssData.getElementsByTagName("title");
var allDate = rssData.getElementsByTagName("pubDate");
source
share