ASP parsing XML and pagination display, sample source code is as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<link href= "Http://www.fx678.com/css/cur_topics.css" rel= "stylesheet" type= "Text/css"/>
<script language= "javascript" type= "Text/ecmascript" src= "Http://www.fx678.com/js/jquery-1.8.0.min.js" >< /script>
<title> Wealth Dynamics Topic </title>
<style type= "Text/css" >
#right_topic
{
Float:right;
Height:auto;
width:690px;
}
#right_topic. Xinhua
{
Clear:both;
width:690px;
Overflow:hidden;
font-size:14px;
Color: #444;
line-height:24px;
}
#right_topic. Xinhua img
{
border:0;
}
#right_topic. Xinhua. Top_cont
{
border:1px solid #ddd;
height:140px;
}
#right_topic. Xinhua. Top_cont. Xh_logo
{
width:270px;
Float:left;
margin:25px 10px;
}
#right_topic. Xinhua. Top_cont. Xh_text
{
Float:right;
width:390px;
font-size:14px;
line-height:22px;
Color: #666;
margin-top:15px;
}
. List
{
Clear:both;
margin-top:15px;
Overflow:hidden;
BORDER-BOTTOM:3PX solid #206295;
}
. List ul
{
margin:0;
padding:0;
}
. List ul Li
{
List-style:none;
border-bottom:1px dotted #E5E5E5;
padding:10px;
}
. List ul Li H4
{
font-family: "Microsoft Yahei";
font-size:18px;
Font-weight:normal;
line-height:22px;
margin:0px;
margin-bottom:5px;
padding:0;
Color: #0761B7;
}
. List ul Li H4 a
{
Color: #206295;
Text-decoration:none;
}
. List ul Li H4 a:hover
{
Text-decoration:underline;
}
. List ul Li Span
{
Float:right;
width:120px;
Color: #999;
font-size:14px;
Text-align:right;
}
. List ul Li P
{
margin:0;
padding:0;
font-size:12px;
}
. List UL li.bg
{
Background: #f5f8fa;
}
#pageZone
{
Background: #F5F6FB;
border-bottom:1px solid #DBE3EE;
margin:10px Auto 20px;
padding:10px 0;
Text-align:center;
}
#pageZone span
{
Background: #FFFFFF;
border:1px solid #D8DADF;
font-size:14px;
height:34px;
line-height:34px;
margin:0px 2px;
PADDING:8PX 12px;
}
#pageZone span A
{
Color: #666;
Text-decoration:none;
}
#pageZone Span.isnow
{
Background: #206295;
border:1px solid #D8DADF;
Color: #FFFFFF;
}
</style>
<script type= "Text/javascript" >
var $m = $ (window.parent.document). Find ("#MyXH08");
$m. Load (function () {
var thish = $ (document). Height () + 30;
$m. Height (thish);
});
</script>
<body style= "width:690px;" >
<!--list information-->
<div class= "List" >
<ul>
<%
Dim Xmldoc,objnodes,pindex,psize,i,http,xmlurl
psize = 10 ' page size
XMLURL = "Http://back.moneypower.cn/news.xml"
REM Page Index
Pindex = Request.QueryString ("P")
If Cint (pindex) > 6 Or Cint (Pindex) < 1 Then
Pindex = 1
End If
REM asynchronously reads an XML source
Set http = Server.CreateObject ("Microsoft.XMLHTTP")
Http.open "Get", Xmlurl,false
Http.send
REM defines variables that read 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%>
<span>
<%= formatdate (mydate,2)%>
</span><a target= "_blank" href= "<%= myLink%>" >
<%= MyTitle%></a><p>
<%= mydescription%>
</p>
</li>
<%
i = i + 1
Next
Else
Response.Write ("No data!") ")
End If
%>
</ul>
</div>
<!--pagination information-->
<div id= "Pagezone" >
<%
If Pindex = 1 Then
%>
<span class= "Disabled" > First page </span>
<span class= "Disabled" ><< prev </span>
<span class= "isnow number" title= "You are browsing this page" >1</span>
<span class= "number" title= "2nd page" >
<a href= "zt_cfdl_list.asp?p=2" >2</a>
</span>
<span class= "Number" title= "3rd page" >
<a href= "Zt_cfdl_list.asp?p=3" >3</a>
</span>
<span class= "Number" title= "4th page" >
<a href= "zt_cfdl_list.asp?p=4" >4</a>
</span>
<span class= "Number" title= "5th page" >
<a href= "Zt_cfdl_list.asp?p=5" >5</a>
</span>
<span class= "number" title= "6th page" >
<a href= "Zt_cfdl_list.asp?p=6" >6</a>
</span>
<span title= "Go to next Page" >
<a href= "zt_cfdl_list.asp?p=<%= Cint (pindex+1)%>" > next page >></a>
</span>
<span title= "Go to the last page" >
<a href= "zt_cfdl_list.asp?p=6" > last page </a>
</span>
<%
ElseIf Pindex = 6 Then
%>
<span class= "Disabled" >
<a href= "zt_cfdl_list.asp?p=1" > First page </a>
</span>
<span title= "Go to previous Page" >
<a href= "zt_cfdl_list.asp?p=<%= Cint (pIndex-1)%>" > Prev </a>
</span>
<span class= "number" title= "1th page" >
<a href= "Zt_cfdl_list.asp?p=1" >1</a>
</span>
<span class= "number" title= "2nd page" >
<a href= "zt_cfdl_list.asp?p=2" >2</a>
</span>
<span class= "Number" title= "3rd page" >
<a href= "Zt_cfdl_list.asp?p=3" >3</a>
</span>
<span class= "Number" title= "4th page" >
<a href= "zt_cfdl_list.asp?p=4" >4</a>
</span>
<span class= "Number" title= "5th page" >
<a href= "Zt_cfdl_list.asp?p=5" >5</a>
</span>
<span class= "number Isnow" title= "You are browsing this page" >6</span>
<span class= "Disabled" > next page >></span>
<span class= "Disabled" title= "go to Last Page" > last page </span>
<%
Else
%>
<span class= "Number" >
<a href= "zt_cfdl_list.asp?p=1" > First page </a>
</span>
<span title= "Go to previous Page" >
<a href= "zt_cfdl_list.asp?p=<%= Cint (pIndex-1)%>" > Prev </a>
</span>
<%
for m = 1 to 6 Step 1
If Cint (pindex) = Cint (M) Then
%>
<span class= "number Isnow" title= "You are browsing this page" ><%= m%></span>
<%
Else
%>
<span class= "number" title= "<%= M%> page" >
<a href= "zt_cfdl_list.asp?p=<%= m%>" ><%= m%></a>
</span>
<%
End If
Next
%>
<span title= "Go to next Page" >
<a href= "zt_cfdl_list.asp?p=<%= Cint (pindex+1)%>" > next page >></a>
</span>
<span title= "Go to the last page" >
<a href= "zt_cfdl_list.asp?p=6" > last page </a>
</span>
<%
End If
%>
</div>
</body>
<%
Public Function formatdate (DateAndTime, para)
On Error Resume Next
Dim y, M, D, H, MI, S, strdatetime
FormatDate = DateAndTime
If not IsNumeric (para) Then Exit Function
If not IsDate (dateandtime) Then Exit Function
y = CStr (year (dateandtime))
m = CStr (Month (DateAndTime))
If Len (m) = 1 Then m = "0" & M
D = CStr (Day (DateAndTime))
If Len (d) = 1 Then D = "0" & D
h = CStr (Hour (DateAndTime))
If Len (h) = 1 Then h = "0" & H
Mi = CStr (Minute (DateAndTime))
If Len (mi) = 1 Then mi = "0" & mi
s = CStr (Second (DateAndTime))
If Len (s) = 1 Then s = "0" & S
Select Case Para
Case "1"
Strdatetime = y & "-" & M & "-" & D & "" & H & ":" & Mi & ":" & S
Case "2"
Strdatetime = y & "-" & M & "-" & D
Case "3"
Strdatetime = y & "/" & M & "/" & D
Case "4"
Strdatetime = y & "Year" & M & "Month" & D & "Day"
Case "5"
Strdatetime = M & "-" & D
Case "6"
Strdatetime = M & "/" & D
Case "7"
Strdatetime = M & "Month" & D & "Day"
Case "8"
Strdatetime = y & "Year" & M & "Month"
Case "9"
Strdatetime = y & "-" & M
Case "10"
Strdatetime = y & "/" & M
Case "11"
Strdatetime = M & "-" & D & "" & H & ":" & mi
Case "12"
Strdatetime = h & ":" & Mi & ":" & S
Case "13"
Strdatetime = y & M & D & H & mi & S
Case "14"
Strdatetime = y & M & D
Case "15"
Strdatetime = h & mi & S
Case "16"
Strdatetime = h & ":" & mi
Case "17"
Strdatetime = y & M & D & H & mi & S
Case "18"
Strdatetime = y & M & D
Case "19"
Strdatetime = y & M
Case Else
Strdatetime = DateAndTime
End Select
FormatDate = Strdatetime
End Function
%>
Effect Diagram (part):