How do I recieve an xml feed with an xmlhttp object?
I have createn an asp document that retrieves feeds such as http://www.nytimes.com/services/xml/rss/nyt/Arts.xml and writes a responce containing the items as html.
Using:
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlHttp.Open "GET", feedurl, false
xmlHttp.Send()
feedxml = xmlHttp.ResponseText
How do I use this to recieve feed xml from feeds that do not end in .xml such as http://news.google.com/nwshp?sourceid=navclient&ned=us&topic=t&output=rss
Thanks for your time.
files that don’t end in xml need to be served as application/xml. you can do that part in the asp that creates them.
now for the bad news. you can’t use ajax to jump out of your domain unless you have a little (very little) cgi/asp program on your server that does the real GET and then re-serves it for your news reader!
function handleServerResponse()
{
if (xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
response = xmlHttp.responseText;
document.getElementById (connect line below)
("divMessage").innerHTML = response;
}
else
{
alert("There was a problem accessing the server: " + xmlHttp.statusText);
}
}
}
divmessage is the empty div where I want to put the data, i might need to repost if it cut off my lines.
Now I ran into a problem because javascript hates cross domain stuff and there was a couple fixes for this but it would be easier to use another language like php, asp, c# or whatever to get the info and store it in a local file and read it from there. That way there is no cross domain problems. But try this, perhaps someone has a better answer.
Good Luck
news flash everyone!! that’s not javascript code you see up there! it’s asp :-S. what error are you getting ? you should try adding the next line of code before executing the send:
objXMLReq.setRequestHeader "Content-Type", "application/xml"
Cheers