Asp 解析 XML并分页显示
Asp 解析 XML并分页显示
Asp 解析 XML并分页显示,演示样例源代码例如以下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<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>財富动力专题</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>
</head>
<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>
</span>
<span class="number" title="第1页">
<a href="zt_CFDL_List.asp?p=1">1</a>
</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 isNow" title="您正在浏览本页">6</span>
<span class="Disabled">下一页>></span>
<span class="Disabled" title="转到最后一页">最后一页</span>
<%
else
%>
<span class="number">
<a href="zt_CFDL_List.asp?p=1">第一页</a>
</span>
<span title="转到上一页">
<a href="zt_CFDL_List.asp? p=<%= Cint(pIndex-1) %>">上一页</a>
</span>
<%
for m = 1 to 6 step 1
if Cint(pIndex) = Cint(m) then
%>
<span class="number isNow" title="您正在浏览本页"><%= m %></span>
<%
else
%>
<span class="number" title="第<%= m %>页">
<a href="zt_CFDL_List.asp?p=<%= m %>"><%= m %></a>
</span>
<%
end if
next
%>
<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>
<%
end if
%>
</div>
</body>
</html> <%
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.NET(五):ASP.net实现真分页显示数据
导读:在上篇文章中,介绍了用假分页实现数据的分页显示 ,而避免了去拖动滚动条.但,假分页在分页的同时,其实是拖垮了查询效率的.每一次分页都得重新查询一遍数据,那么有没有方法可以同时兼顾效率和分页呢,那 ...
- ASP.NET(四):ASP.net实现假分页显示数据
导读:在做数据查询的时候,有的时候查询到的数据有很多.通常呢,我们一般都是去拖动右侧边的滚动条.但是,有了分页后,我们就可以不必是使用滚动条,而直接通过分页查看我们想要的数据.在分页的过程中,有分为真 ...
- xpath与nodejs解析xml
测试xpath的工具 http://www.freeformatter.com/xpath-tester.html#ad-output http://www.xpathtester.com/test ...
- CSS控制XML与通过js解析xml然后通过html显示xml中的数据
使用CSS控制XML的显示 book.css bookname{ display:block;color:Red} author{ display:block;font-style:italic} p ...
- 《ASP.NET1200例》<asp:DataList>分页显示图片
aspx页面代码 <asp:DataList ID="dlPhoto" runat="server" Height="137px" W ...
- ASP.NET使用ListView数据绑定控件和DataPager实现数据分页显示(一)
为什么使用ListView+DataPager的方式实现分页显示? .net提供的诸多数据绑定控件,每一种都有它自己的优点和缺点.如果需要对数据进行操作,如果数据量不大的情况下,DataList和Gr ...
- cocos2d-x 显示中文字符和解析XML文件 转载
源地址:http://codingnow.cn/cocos2d-x/1038.html 在cocos2d-x中直接显示中文的时候会出现乱码,虽然在实际开发中把字符串直接写在代码里也不是好的做法,但是有 ...
- asp.net gridview 分页显示不出来的问题
使用gridview分页显示,在点击第二页的时候显示空白,无数据. 原因是页面刷新,绑定datatable未执行 解决方法: 1.将datatable设置为静态 2.在OnPageIndexChang ...
- C#/ASP.NET MVC微信公众号接口开发之从零开发(二) 接收微信消息并且解析XML(附源码)
文章导读: C#微信公众号接口开发之从零开发(一) 接入微信公众平台 微信接入之后,微信通过我们接入的地址进行通信,其中的原理是微信用户发送消息给微信公众账号,微信服务器将消息以xml的形式发送到我们 ...
随机推荐
- [UOJ#132][BZOJ4200][luogu_P2304][NOI2015]小园丁与老司机
[UOJ#132][BZOJ4200][luogu_P2304][NOI2015]小园丁与老司机 试题描述 小园丁 Mr. S 负责看管一片田野,田野可以看作一个二维平面.田野上有 \(n\) 棵许愿 ...
- redis学习(五)事务
事务是一个单独的隔离操作:事务中的所有命令都会序列化.按顺序地执行.事务在执行的过程中,不会被其他客户端发送来的命令请求所打断. 1.事务基本命令: multi:标记一个事务块的开始 exec:执行所 ...
- Ubuntu 查看默认软件安装位置
tags: Linux 方法 1:在命令行输入:dpkg -L 软件包名: 方法 2:在/var/cache/apt/archives找的你安装程序的包,然后用gdebi-gtk+软件包名可以查看具体 ...
- JavaScript 笔记(1) -- 基础 & 函数 & 循环 & ...
目录(代码编写): 显示数据 语法 变量 & 变量类型 对象 函数 事件 字符串 运算符 条件语句 循环语句 Break 和 Continue 使用 JS 近两年,现整理下一些基本: HTML ...
- 沼泽鳄鱼(bzoj 1898)
Description 潘塔纳尔沼泽地号称世界上最大的一块湿地,它地位于巴西中部马托格罗索州的南部地区.每当雨季来临,这里碧波荡漾.生机盎然,引来不少游客.为了让游玩更有情趣,人们在池塘的中央建设了几 ...
- pat 甲级 1080. Graduate Admission (30)
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- 用 config drive 配置网络
上一节最后问了大家一个问题:如果 subnet 没有开 DHCP,会是怎样一个情况? 在其他条件不变的情况下,cloud-init 依然会完成那 3 个步骤,也就是说网卡还是会被配置成 dhcp 模式 ...
- .net web api ioc unity usage
1.use nuget to install unity.webapi 2.add configurations in application_start folder using Microsoft ...
- PowerDesigner 中将Comment(注释)及Name(名称)内容互相COPY的VBS代码
在用PowerDesigner时.常常在NAME或Comment中写中文在Code中写英文.Name只会显示给我们看,Code会使用在代码中.但Comment中的文字会保存到数据库TABLE的Desc ...
- 基址重定位表&.reloc节区
第16-17章 - 基址重定位表&.reloc节区 @date: 2016/11/31 @author: dlive 0x01 PE重定位 若加载的是DLL.SYS文件,且在ImageBase ...