Spudhead
12-19-2006, 11:15 AM
I'm getting a little nervous that I'm not doing this quite right. I'd appreciate any advice - I've looked all over at AJAX / XML DOM / related articles and I've stilll not seen what I'd describe as a complete solution.
So I have an XML RSS news feed file. (This will be generated by an ASP backend, that's no worries.) Obviously, for RSS news aggregators and stuff, we need to make that file available. It is, here (http://ben.ifthengo.com/rss/rss.xml).
Being all swishy and Web 2.0, we want some AJAX in there. Some (prototype-powered) AJAX:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="prototype-1.4.0.js"></script>
<script type="text/javascript">
function getNews(){
var url = 'http://ben.ifthengo.com/rss/rss.xml';
var pars = '';
var myAjax = new Ajax.Request( url, { method: 'get', parameters: pars, onComplete: showResponse });
}
function showResponse(originalRequest){
//$('newsDiv').innerHTML = originalRequest.responseText;
var xml = originalRequest.responseXML;
$('newsBox').value = originalRequest.responseText;
}
</script>
</head>
<body onLoad="getNews()">
<!--<div id="newsDiv">Latest news</div>-->
<textarea id="newsBox" rows="10" cols="50"></textarea>
</body>
</html>
As you can probably see, it's at this point that I start to get confounded. I've got my XML, what the dickens am I supposed to do with it? I want a pretty news box with rounded edges and links and scrollableness and all that stuff.
I could get the responseXML as a DOM object and traverse it in Javascript, generating HTML. Not entirely sure how to do that, the examples I've seen appear to descend quickly into browser-detection; I don't want to go there. I'm using prototype.js - surely that's got some sort of XML-parsing... thing? Right?
I could also write an XSLT for it - I'm reasonably familiar with XSL, I reckon I could muddle through. But I've not written one that'll just generate a BIT of a page before, and I'm still not sure how I'd apply an XSLT to a XML DOM object, or even simply a string of XML text. I've only ever done it with XML files.
So... I need a bit of help to get me the final mile. This has, eventually, got to go on the front page of a corporate web design agency, so it's got to be something that code-minded clients can peek at and and go "mmm, that's an elegant and novel use of technology. I like what you've done there."
And if I could have it by about 4pm, that'd be, like, totally cool. :thumbsup:
Thanks for any replies. :)
So I have an XML RSS news feed file. (This will be generated by an ASP backend, that's no worries.) Obviously, for RSS news aggregators and stuff, we need to make that file available. It is, here (http://ben.ifthengo.com/rss/rss.xml).
Being all swishy and Web 2.0, we want some AJAX in there. Some (prototype-powered) AJAX:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="prototype-1.4.0.js"></script>
<script type="text/javascript">
function getNews(){
var url = 'http://ben.ifthengo.com/rss/rss.xml';
var pars = '';
var myAjax = new Ajax.Request( url, { method: 'get', parameters: pars, onComplete: showResponse });
}
function showResponse(originalRequest){
//$('newsDiv').innerHTML = originalRequest.responseText;
var xml = originalRequest.responseXML;
$('newsBox').value = originalRequest.responseText;
}
</script>
</head>
<body onLoad="getNews()">
<!--<div id="newsDiv">Latest news</div>-->
<textarea id="newsBox" rows="10" cols="50"></textarea>
</body>
</html>
As you can probably see, it's at this point that I start to get confounded. I've got my XML, what the dickens am I supposed to do with it? I want a pretty news box with rounded edges and links and scrollableness and all that stuff.
I could get the responseXML as a DOM object and traverse it in Javascript, generating HTML. Not entirely sure how to do that, the examples I've seen appear to descend quickly into browser-detection; I don't want to go there. I'm using prototype.js - surely that's got some sort of XML-parsing... thing? Right?
I could also write an XSLT for it - I'm reasonably familiar with XSL, I reckon I could muddle through. But I've not written one that'll just generate a BIT of a page before, and I'm still not sure how I'd apply an XSLT to a XML DOM object, or even simply a string of XML text. I've only ever done it with XML files.
So... I need a bit of help to get me the final mile. This has, eventually, got to go on the front page of a corporate web design agency, so it's got to be something that code-minded clients can peek at and and go "mmm, that's an elegant and novel use of technology. I like what you've done there."
And if I could have it by about 4pm, that'd be, like, totally cool. :thumbsup:
Thanks for any replies. :)