<style type=
body {color: white;background: #52616F;}
a { color: white; }
</style>
<meta http-equiv=
<style type=
body {
background-color: #52616F;
color: white;
}
a {
color: pink;
}
#feed {
background: #52616F;
border: 1px dotted #ccc;
height: 400px;
overflow: auto;
width: 400px
}
</style></head><body>
<script language=
function showFeed(xmlUrl, xslUrl) {
var feed = document.getElementById('feed');
//clear feed div
while(feed.hasChildNodes()){
feed.removeChild(feed.childNodes[0]);
}
//append new htmlfragment
feed.appendChild(getHtmlFragment(xmlUrl, xslUrl));
}
function getHtmlFragment(xmlUrl, xslUrl) {
var xslStylesheet;
var xsltProcessor = new XSLTProcessor();
//load the xml file
var xmlSource = getResponseXml(xmlUrl).responseXML;
//load the xsl file into the xslt Processor
xslStylesheet = getResponseXml(xslUrl).responseXML;
xsltProcessor.importStylesheet(xslStylesheet);
return xsltProcessor.transformToFragment(xmlSource, document);
}
function getResponseXml(xmlUrl) {
var xmlHttp = ajaxFunction();
xmlHttp.open("GET", xmlUrl, false);
xmlHttp.send(null);
return xmlHttp;
}
function ajaxFunction()
{
var xmlHttp;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser does not support AJAX!");
return false;
}
}
}
return xmlHttp;
}
</script>
<p>Retrieves an xml rss feed and xsl stylesheet with XMLHttpRequest().
Applies the stylesheet to the xml. Adds the fragment to the div.</p>
<a href=
<a href=
<center><div id=
</body>
No comments:
Post a Comment