Asp 解析 XML并分页显示源码(2)


<body style="width: 690px;">
<!-- 列表信息 -->
<div class="list">
<ul>
<%
Dim xmlDoc,objNodes,pIndex,pSize,i,http,xmlUrl
pSize = 10 '页大小
xmlUrl ="http://back.moneypower.cn/news.xml"

REM 页索引
pIndex = Request.QueryString("p")
if Cint(pIndex) > 6 Or Cint(pIndex) < 1 then
pIndex = 1
end if

REM 异步读取XML源
Set http = Server.CreateObject("Microsoft.XMLHTTP")
http.open "GET",xmlUrl,false
http.send

REM 定义 读取XML 的变量
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async = false
xmlDoc.validateOnParse = false
xmlDoc.load(http.ResponseXML)

Set objNodes = xmlDoc.getElementsByTagName("item")

if objNodes.length > 0 then
i = 0
For j = (pSize*(pIndex-1)) to (pSize*pIndex-1) step 1
myTitle = objNodes(j).childNodes(0).text
myDate = objNodes(j).childNodes(3).text
myDescription = objNodes(j).childNodes(2).text
link = Server.URLEncode(objNodes(j).childNodes(1).text)
myLink = "http://www.fx678.com/news/currency/XH08NewsContent.asp?u=" & link
%>
<% if i Mod 2 = 0 then %>
<li class="bg">
<% else %>
<li>
<% end if %>
<h4>
<span>
<%= FormatDate(myDate,2) %>
</span><a target="_blank" href="<%= myLink %>">
<%= myTitle %></a></h4>
<p>
<%= myDescription %>
</p>
</li>
<%
i = i + 1
Next
Else
Response.Write("暂无数据!")
End If
%>
</ul>
</div>
<!-- 分页信息 -->
<div id="pageZone">
<%
if pIndex = 1 then
%>
<span class="Disabled">第一页</span>
<span class="Disabled"><<上一页</span>
<span class="isNow number" title="您正在浏览本页">1</span>
<span class="number" title="第2页">
<a href="zt_CFDL_List.asp?p=2">2</a>
</span>
<span class="number" title="第3页">
<a href="zt_CFDL_List.asp?p=3">3</a>
</span>
<span class="number" title="第4页">
<a href="zt_CFDL_List.asp?p=4">4</a>
</span>
<span class="number" title="第5页">
<a href="zt_CFDL_List.asp?p=5">5</a>
</span>
<span class="number" title="第6页">
<a href="zt_CFDL_List.asp?p=6">6</a>
</span>
<span title="转到下一页">
<a href="zt_CFDL_List.asp?p=<%= Cint(pIndex+1) %>">下一页>></a>
</span>
<span title="转到最后一页">
<a href="zt_CFDL_List.asp?p=6">最后一页</a>
</span>
<%
elseif pIndex = 6 then
%>
<span class="Disabled">
<a href="zt_CFDL_List.asp?p=1">第一页</a>
</span>
<span title="转到上一页">
<a href="zt_CFDL_List.asp?p=<%= Cint(pIndex-1) %>">上一页</a>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2009.html