js 實現(xiàn)讀取遠程xml
<script language="JavaScript">
var xmlDoc=new ActiveXObject("Microsoft.xmlDOM");
xmlDoc.async=false;
xmlDoc.load(" //xmlDoc.loadxml("<description>品格</description>");
var root=xmlDoc.documentElement;
var number=root.selectNodes("channel/item").length;
if(number<=10)
alert("對不起,該新聞條數已經少于要顯示的新聞條數!");
else
{
document.writeln("<p align='center' class='font'>"+root.childNodes(0).childNodes(0).text+"<p>");
document.writeln("<p class='indent'>"+root.childNodes(0).childNodes(1).text+"</p>");
document.writeln("<p class='indent'>"+root.childNodes(0).childNodes(2).text+"</p>");
for(var i=0;i<10;i++)
{
document.writeln("<b>"+root.childNodes(0).childNodes(5+i).childNodes(0).text+"</b><br/><br/>");
document.writeln("<small>"+root.childNodes(0).childNodes(5+i).childNodes(4).text+" "+root.childNodes(0).childNodes(5+i).childNodes(3).text+"</small><br/>");
document.writeln("<small><a href='"+root.childNodes(0).childNodes(5+i).childNodes(1).text+"'>"+root.childNodes(0).childNodes(5+i).childNodes(1).text+"</a></small><br/><br/>");
document.writeln("<p class='indent'>"+root.selectNodes("channel/item/description")(i).text+"</p><br/><br/>");
}
}
</script>
asp 實現(xiàn)讀取遠程xml文件
<%
dim xmlDoc
dim root
dim number
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET","
http.send
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.Async=False
xmlDoc.ValidateOnParse=False
xmlDoc.Load(http.ResponseXML)
set root=xmlDoc.documentElement
number=root.selectNodes("channel/item").length
if number<=10 then
%>
<script language="vbscipt">
msgbox "對不起,該新聞條數已經少于要顯示的新聞條數!"
</script>
<%
else
response.write "<p align='center' class='font'>" & root.childNodes(0).childNodes(0).text & "<p>"
response.write "<p class='indent'>" & root.childNodes(0).childNodes(1).text & "</p>"
response.write "<p class='indent'>" & root.childNodes(0).childNodes(2).text & "</p>"
for i=0 to 9
response.write "<b>" & root.childNodes(0).childNodes(5+i).childNodes(0).text & "</b><br/><br/>"
response.write "<small>" & root.childNodes(0).childNodes(5+i).childNodes(4).text & root.childNodes(0).childNodes(5+i).childNodes(3).text & "</small><br/>"
response.write "<small><a href='" & root.childNodes(0).childNodes(5+i).childNodes(1).text & "'>" & root.childNodes(0).childNodes(5+i).childNodes(1).text & "</a></small><br/><br/>"
response.write "<p class='indent'>" & root.selectNodes("channel/item/description")(i).text & "</p><br/><br/>"
next
end if
%>
該文章在 2012/7/9 8:41:51 編輯過