atom_js.asp
程序员文章站
2022-06-20 07:57:16
复制代码 代码如下:<%  ...
复制代码 代码如下:
<%
' i converted some of your example found on http://www.iteam5.net/francesco/atom/ over to jscript.
' feel free to use it and keep up the good work.
' tyson kopczynski
' tyson@cco.com
function atom(strurl)
{
var objxml = new activexobject("msxml2.domdocument.3.0");
objxml.async = false;
objxml.setproperty("serverhttprequest", true);
objxml.validateonparse = true;
objxml.preservewhitespace = false;
if (!objxml.load(strurl))
{
var array = new array();
response.write("<p>error<br>code: " + objxml.parseerror.errorcode)
response.write("<br>linea/col: " + objxml.parseerror.line & "/" + objxml.parseerror.linepos)
response.write("</p>")
return(array)
}
else
{
var objnodelist = objxml.getelementsbytagname("entry");
var arrdicts = new array(objnodelist.length);
for (var i=0; i<objnodelist.length; i++)
{
arrdicts[i] = new activexobject("scripting.dictionary");
arrdicts[i].item("issued") = objnodelist[i].getelementsbytagname("issued")[0].firstchild.nodevalue
arrdicts[i].item("id") = objnodelist[i].getelementsbytagname("id")[0].firstchild.nodevalue
arrdicts[i].item("link") = objnodelist[i].getelementsbytagname("link")[1].getattribute("href")
arrdicts[i].item("author") = objnodelist[i].getelementsbytagname("author")[0].xml
arrdicts[i].item("title") = objnodelist[i].getelementsbytagname("title")[0].firstchild.nodevalue
arrdicts[i].item("content") = objnodelist[i].getelementsbytagname("content")[0].xml
}
return(arrdicts)
}
}
var blogurl = "http://taosage-net.blogspot.com/atom.xml";
var blogitems = atom(blogurl);
response.write("<strong>")
response.write("<a href='" + blogitems[0].item("link") + "'>" + blogitems[0].item("title") + "</a>")
response.write("</strong>")
response.write("<table width='100%' cellspacing='0' cellpadding='0'>")
response.write("<tr>")
response.write("<td width='10' rowspan='2'> </td>")
response.write("<td>" + blogitems[0].item("content") + "<br></td>")
response.write("</tr>")
response.write("<tr>")
response.write("<td>posted by " + blogitems[0].item("author") + " @ " + blogitems[0].item("issued") + "</td>")
response.write("</tr>")
response.write("</table>")
%>
下一篇: 鲍鱼怎么做煲汤才会营养又好喝
推荐阅读