Asp 解析 XML并分页显示源码

来源:爱站网时间:2020-05-12编辑:网友分享
XML在很多操作中是非常标准的,而ASP在WEB编程中是很流行的,其实我们在操作中也是自己不断的摸索后才得出的结论,接下来爱站技术频道就为初学者讲解Asp 解析 XML并分页显示源码吧。

XML在很多操作中是非常标准的,而ASP在WEB编程中是很流行的,其实我们在操作中也是自己不断的摸索后才得出的结论,接下来爱站技术频道就为初学者讲解Asp 解析 XML并分页显示源码吧。

Asp 解析 XML并分页显示,示例源码如下:

复制代码 代码如下:
 

 

 

 

 








 


 

 

  • 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) 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
    %>







  •  



  • i = i + 1
    Next
    Else
    Response.Write("暂无数据!")
    End If
    %>


  •  


 

 


if pIndex = 1 then
%>
第一页

1

2


3


4


5


6


下一页>>


最后一页

elseif pIndex = 6 then
%>

第一页


上一页


1


2


3


4


5

6
下一页>>
最后一页
else
%>

第一页


上一页

for m = 1 to 6 step 1
if Cint(pIndex) = Cint(m) then
%>

else
%>



end if
next
%>

下一页>>


最后一页

end if
%>

 

 




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 & "年" & m & "月" & d & "日"
Case "5"
strDateTime = m & "-" & d
Case "6"
strDateTime = m & "/" & d
Case "7"
strDateTime = m & "月" & d & "日"
Case "8"
strDateTime = y & "年" & m & "月"
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
%>

效果图(部分):

上述是爱站技术频道小编为大家带里的Asp 解析 XML并分页显示源码,其实任何开发都需要承担风险,但是初学者只要选择了适合自己的方法,在未来就会占据优势。

 

 

上一篇:asp中cint与clng的区别分析

下一篇:String.indexOf 方法介绍

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载