账号通
    

账号  

密码  

1751

查看

4

回复
主题:请教4.0版本中关于对XML的操作 [收藏主题] 转到:  
slm 当前离线

3

主题

0

广播

0

粉丝
添加关注
级别:学前班

用户积分:232 分
登录次数:2 次
注册时间:2007/12/26
最后登录:2008/1/8
slm 发表于:2008/1/3 17:09:00   | 显示全部帖子 查看该作者主题 楼主 
科汛在线商城系统(NET)

我有一个网站后台需要改造,目前完成度是90%,由于开发并不是我,加上本人对这个实在是菜鸟级,所以有个问题想请教,我的主页面是一个FLASH程序读取一个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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>新闻中心</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #E6E9EA;
background-image: url(../images/page_bk.jpg);
}
-->
</style>
<link href="../images/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #FF0000}
-->
</style>
</head>

<body>
<!--#include file="../connection/conn.asp"-->
<%
If request.Form("Submit")<>"" Then
selID=request.Form("selID")

If selID="" Then
return_message "您必须选择6条新闻以供生成列表!","-1"
response.end
End If

selID=Split(selID,",")

If UBound(selID)>5 Then
return_message "首页列表只需要6条新闻,\n请减少您的选择!","-1"
response.end
End If

xml_read=""
xml=server.mappath("\index_xml.txt")
set fso=server.createObject("Scripting.FileSystemObject")
fso.deletefile server.mappath("\index.xml")
Set fso=nothing

set fso=server.createObject("Scripting.FileSystemObject")
set file = fso.opentextfile(xml, 1)
do until file.AtEndOfStream
If xml_read="" Then
xml_read=file.readline
Else
xml_read=xml_read & vbcrlf & file.readline
End if
Loop
file.close
Set file=Nothing
Set fso=Nothing

xml_read=xml_read & vbcrlf & vbcrlf & "<news>"

For i=0 To UBound(selID)
sql="select ID,Title,aDate from tNews where ID=" & Trim(selID(i))
Set rs=conn.execute(sql)
If Not(rs.eof And rs.bof) then
id=rs(0)
title=Trim(rs(1))
aDate=rs(2)
If IsDate(aDate) Then aDate=FormatDateTime(aDate,2)
xml_read=xml_read & vbcrlf & "<newsitem id=""" & i & """ date=""" & aDate & """ title=""" & title & """
picurl=""flash/images/news/01.jpg"" url=""news/show.asp?id=" & id & """ />"
End if
rs.close
next
conn.close

xml_read=xml_read & vbcrlf & "</news>"
xml_read=xml_read & vbcrlf & vbcrlf & "<piantou url=""flash/mazda.swf""></piantou>" & vbcrlf & "</list>"

Set objStream = Server.CreateObject("ADODB.Stream")
With objStream
.Open
.Charset = "utf-8"
.Position = objStream.Size
.WriteText=xml_read
.SaveToFile server.mappath("/index.xml"),2
.Close
End With
Set objStream = Nothing

jump_message "成功首页信息列表生成!","../ok.asp"
End If

unit=request.querystring("unit")
file=request.ServerVariables("SCRIPT_NAME")
pageno=request("pageno")
if pageno="" then pageno="1"
%>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="778" height="93">
<param name="movie" value="../images/top.swf" />
<param name="quality" value="high" />
<embed src="../images/top.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="778" height="93"></embed>
</object></td>
</tr>
</table>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="778"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="778" height="224">
<param name="movie" value="../images/menu.swf" />
<param name="quality" value="high" />
<embed src="../images/menu.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="778" height="224"></embed>
</object></td>
</tr>
<tr>
<td><img src="../images/bg4.jpg" width="778" height="33" /></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="778" height="8" background="../images/bg5.jpg"><img name="" src="" width="1" height="1" alt=""
/></td>
<td><img name="" src="" width="1" height="1" alt="" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="181" align="left" valign="top" background="../images/left-bg8.jpg" bgcolor="#FFFFFF"><table
width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="176" border="0" cellpadding="0" cellspacing="0" bgcolor="#ECECEC">
<tr>
<td height="10"><img name="" src="" width="1" height="1" alt="" /></td>
</tr>
<tr>
<td><img src="../images/newscenter.jpg" width="176" height="35" /></td>
</tr>
<tr>
<td height="33" bgcolor="#FFFFFF"><table width="160" border="0" align="center" cellpadding="0"
cellspacing="0" class="left-menu">
<tr>
<td width="20" align="center"><img src="../images/ball.jpg" width="13" height="13" /></td>
<td align="left">&nbsp;<a href="../ok.asp" class="left-menu">返回管理首页</a></td>
</tr>
</table></td>
</tr>
<tr>
<td height="1" bgcolor="#666666"><img name="" src="" width="1" height="1" alt="" /></td>
</tr>
</table></td>
</tr>
<tr>
<td height="300" align="center" valign="bottom"><img src="../images/car1.gif" width="168" height="133"
/></td>
</tr>
<tr>
<td height="100" align="center" valign="bottom"><img src="../images/heart.gif" width="73" height="62"
/></td>
</tr>
<tr>
<td align="center" valign="bottom">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="bottom"><img src="../images/juli.jpg" width="153" height="48" /></td>
</tr>
<tr>
<td align="center" valign="bottom">&nbsp;</td>
</tr>
</table></td>
<td width="597" valign="top" bgcolor="#FFFFFF"><table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr background="../images/bg5.jpg">
<td height="15">&nbsp;</td>
</tr>
<tr>
<td><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="left" bgcolor="#FFFFFF"><%
select case unit
case "企业新闻"
%>
<img src="../images/qyxw.jpg" width="561" height="32" />
<% case "服务快讯"%>
<img src="../images/fwkx.jpg" width="561" height="32" />
<% case "促销活动"%>
<img src="../images/cxhd.jpg" width="561" height="32" />
<% case else%>
<img src="../images/news.jpg" width="561" height="32" />
<%end select%> </td>
</tr>
</table></td>
</tr>
</table>
<form id="form1" name="form1" method="post" action="creat.asp">
<table width="94%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="40" align="left"><strong class="font14px STYLE1">特别提示:为保证首页Flash的最佳显示效
果,生成首页动态新闻列表时,所选新闻条数为 6 条。</strong></td>
</tr>
<%
sql="select ID,Unit,Title,aDate from tNews"
If unit<>"" Then sql=sql & " where Unit='" & unit & "'"
sql=sql & " order by ID desc"
rs.open sql,conn,1,1
rs.pagesize=cint(pgsz)
all=rs.recordcount
total=int(all/pgsz*-1)*-1
current=(int(pageno)-1)*pgsz
if int(pageno)>1 then rs.move current
i=1
do while not rs.eof and i<=pgsz
id=rs(0)
unit=Trim(rs(1))
title=Trim(rs(2))
aDate=rs(3)
If IsDate(aDate) Then aDate=FormatDateTime(aDate,1)
%>
<tr>
<td align="center"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"
class="font14px">
<tr>
<td width="10" align="center"><input name="selID" type="checkbox" id="selID" value="<%=id%>"
/></td>
<td height="28" align="left">.<a href="show.asp?id=<%=id%>" target="_blank"><%=title%></td>
<td width="120" align="center">(<%=aDate%>)</td>
</tr>
</table></td>
</tr>
<tr>
<td height="1" align="center" background="../images/line.jpg"><img src="../images/line.jpg" /></td>
</tr>
<%
rs.movenext
Loop
rs.close
conn.close
%>
<tr>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td align="center"><input name="Submit" type="submit" class="button-sty" value="生成首页动态信息列
表" /></td>
</tr>
</table>
</form>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="font14px">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center"> 共<%=all%>条/<%=total%>页,目前为第<%=pageno%>页&nbsp;&nbsp;
<%
if int(pageno)>1 then
response.write "<a href=""" & file & "?unit=" & unit & "&pageno=1"">首页</a>"
else
response.write "首页"
end if
response.write "|"
if total>1 and int(pageno)>1 then
response.write "<a href=""" & file & "?unit=" & unit & "&pageno=" & int(pageno)-1 & """>上一页</a>"
else
response.write "上一页"
end if
response.write "|"
if total>1 and int(pageno)<total then
response.write "<a href=""" & file & "?unit=" & unit & "&pageno=" & int(pageno)+1 & """>下一页</a>"
else
response.write "下一页"
end if
response.write "|"
if int(pageno)<total then
response.write "<a href=""" & file & "?unit=" & unit & "&pageno=" & total & """>末页</a>"
else
response.write "末页"
end if
%> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<!-- #BeginLibraryItem "/Library/buttom.lbi" -->
<style type="text/css">
<!--
.STYLE1 {
color: #999999;
font-size: 12px;
}
-->
</style>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="778" height="46" align="right" background="../images/button-bg.jpg" class="button-white"><a
href="../public/map.htm" class="button-white">网站地图</a> | 网站导航 | 法律声明 | <a href="../public/link.htm"
class="button-white">联系我们</a></td>
</tr>
<tr>
<td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="778" height="30" align="right" bgcolor="#EEE9E6"><span class="STYLE1">&copy; 2007 版权所有</span></td>
</tr>
</table></td>
</tr>
</table>
<!-- #EndLibraryItem -->
<%
If request.cookies("leader")("login")="" Then
jump_message "您必须登录才能使用管理系统!","/index.htm"
End If

function jump_message(message,address)
response.write "<script language=javascript>alert(""" & message & """);location.href=""" & address & """;</script>"
end function
%>
</body>
</body>
</html>

原本我以为只需要改掉相应的ID名就可以,后来发现在对MDB的操作上,2个操作方法不一样,由于不清楚科讯的数据库操作方法,所以只有请教各位大侠了,其实比较简单,就是在数据库提取文章的生成日期、文章标题(有没有文章所属频道和专题无所谓)然后通过写入XML在首页显示就可以了,或者是直接用科讯内部的 {LB_通用推荐文章} 这个模块来生成,也许简单一点,但是由于水平有限,所以..........

希望有大侠能现身指点,非常感谢

 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
slm 当前离线

3

主题

0

广播

0

粉丝
添加关注
级别:学前班

用户积分:232 分
登录次数:2 次
注册时间:2007/12/26
最后登录:2008/1/8
slm 发表于:2008/1/4 11:57:00   | 显示全部帖子 查看该作者主题 沙发 
 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
slm 当前离线

3

主题

0

广播

0

粉丝
添加关注
级别:学前班

用户积分:232 分
登录次数:2 次
注册时间:2007/12/26
最后登录:2008/1/8
slm 发表于:2008/1/3 17:23:00   | 显示全部帖子 查看该作者主题 藤椅 
科汛在线商城系统(NET)
主要是有一个对数据库中数据提取的过程
 
  支持(0) | 反对(0) 回到顶部顶端 回到底部底部
<上一主题 | 下一主题 >
Powered By KesionCMS Version X1
厦门科汛软件有限公司 © 2006-2016 页面执行0.10938秒 powered by KesionCMS 9.0