xml|程序|数据|数据库
<%...@ Language=VBScript %>
<!--#include file="config.asp"-->
<%...
f=trim(Request("id"))
biaoti=Request("title")
neirong=Request("neirong")
IF biaoti="" then
Response.Write "请输入标题"
Response.End
end if
if neirong="" then
Response.Write "内容不能为空"
Response.End
end if
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(server.mappath(xfolder & "/" & tname2))
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
sql="//" & rootnode & "/" & snode & "[index=" & f & "]"
set node2=xd.selectSingleNode(sql)
node2.childnodes(0).text=biaoti
xd.save server.mappath(xfolder & "/" & tname2)
set node2=nothing
set xd=nothing
filen=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & filen)
set xd2=server.CreateObject("msxml2.domdocument")
xd2.load(strSourceFile)
if xd2.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
xd2.childNodes(1).childNodes(0).childNodes(0).text=biaoti
xd2.childNodes(1).childNodes(0).childNodes(1).text=neirong
xd2.save strSourceFile
set node2=nothing
set xd2=nothing
%>
<script language="javascript">...
window.close();
</script>
xml分为三种,
index.xml保存一个最大的索引 ,相当于一个序列。
flfgcx_list.xml为一个目录,里面保存了所有的信息的索引信息
另一种就是内容xml,每一种法律都有一个文件。文件名为一个数字,当录入当前的法律的时候自动创造的,名字根据index.xml中的数字 + 1 生成。
xml文件的如下:
1 . 目录 (flfgcx_list.xml)
<?xml version="1.0" encoding="gb2312"?>
<flfg>
<flfgcx>
<name>中华人民共和国宪法</name>
<index>1</index>
</flfgcx>
<flfgcx><name>中华人民共和国工会法</name><index>2</index></flfgcx><flfgcx><name>吉林省实施《中华人民共和国工会法》若干规定</name><index>3</index></flfgcx><flfgcx><name>中华人民共和国劳动法</name><index>4</index></flfgcx><flfgcx><name>中华人民共和国公司法</name><index>5</index></flfgcx><flfgcx><name>中华人民共和国中外合资经营企业法</name><index>6</index></flfgcx><flfgcx><name>中华人民共和国企业劳动争议处理条例 </name><index>7</index></flfgcx><flfgcx><name>中华人民共和国婚姻法</name><index>8</index></flfgcx><flfgcx><name>中华人民共和国妇女权益保障法</name><index>9</index></flfgcx><flfgcx><name>最高人民法院关于适用《中华人民共和国婚姻法》若干问题的解释(一)</name><index>10</index></flfgcx><flfgcx><name>吉林省计划生育条例</name><index>11</index></flfgcx><flfgcx><name>中华人民共和国体育法</name><index>12</index></flfgcx><flfgcx><name>全民健身计划纲要</name><index>13</index></flfgcx><flfgcx><name>职工安康互助合作保险计划</name><index>14</index></flfgcx></flfg>
2 . 一个内容(?.xml 其中?是一个数字)
<?xml version="1.0" encoding="gb2312"?>
<flfg>
<flfgcx>
<name>中华人民共和国宪法</name>
<content> 序 言
中国是世界上历史最悠久的国家之一。中国各族人民共同创造了光辉灿烂的文化,具有光荣的革命传统。
一八四○年以后,封建的中国逐渐变成半殖民地、半封建的国家。中国人民为国家独立、民族解放和民主自由进行了前仆后继的英勇奋斗。
二十世纪,中国发生了翻天覆地的伟大历史变革。
一九一一年孙中山先生……
</content>
</flfgcx>
</flfg>
3 . 索引(index.xml)
<?xml version="1.0" encoding="gb2312"?>
<flfg>
<index>15</index>
</flfg>
此程序包含对法律数据的增删改操作,具体程序如下:
1 . 录入界面(add.asp)
<html>
<%...Response.Write(request("tt"))%>
<!--#include file="config.asp"-->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title><%=cname%>录入界面</title>
</head>
<style>...
td{...}{font-size:13;}
</style>
<body>
<table border="1" cellpadding="0" cellspacing="0" align="center" bordercolor="black" width=760 bgcolor="#c4f578" style="border-collapse:collapse">
<tr><td>
<tr><td>
<table border="0" cellspacing="0" cellpadding="0" width="80%" height="40" align="center">
<tr><td height="40" bgcolor="#ffcc00"><div align="center"><font size="6" color="#ff3300"><%=cname%>录入界面</FONT></DIV></TD></TR></TABLE>
<hr noshade size="1" color="#ff9900">
<p align=left>说明:在每一段的开始的<font color=red>空格</font>必须是<font color=red>全角</font>的空格。否则提交后不能安目前的段落格式显示。
<form name="name" action="addsubmit.asp" method="post">
<table border="1" cellspacing="0" cellpadding="0" width="80%" height="300" bordercolordark="#f8ffe1" bordercolorlight="#ff9900" align="center">
<tr><td align=center width=70>标题:</TD>
<td> <INPUT style="WIDTH: 100%" name="biaoti"> </TD></TR>
<!--
<tr><td align=center>文件名:</TD>
<td> <INPUT style="WIDTH:100%" name="filename"> </TD></TR>-->
<tr><td align="center">内容:</TD>
<td><TEXTAREA name="neirong" rows=30 cols=73></TEXTAREA></TD>
</TR>
<tr><td colspan="2"> <p align="center"><input type="submit" value="提交" id=submit1 name=submit1>
<input type="reset" value="全部重新填写" id=reset1 name=reset1> <input type=button value="关闭" id=button1 name=button1>
</P></TD></TR></TABLE></FORM>
</td></tr></table>
</body>
2 . 录入提交界面 (addsubmit.asp)
<%...@ Language=VBScript %>
<!--#include file="config.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%...
dim biaoti,neirong,filename
biaoti=Request.Form("biaoti")
'f=request("filename")
neirong=request("neirong")
IF biaoti="" then
Response.Write "请输入标题"
Response.End
end if
if neirong="" then
Response.Write "内容不能为空"
Response.End
end if
set xd2=server.CreateObject("msxml2.domdocument")
xd2.async = false
xd2.load(server.mappath(xfolder & "/" & tname))
if xd2.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
f=xd2.childNodes(1).childNodes(0).text
f=clng(f)+1
xd2.childNodes(1).childNodes(0).text=f
xd2.save server.mappath(xfolder & "/" & tname)
set xd2=nothing
filen=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & filen)
set fso=server.CreateObject("scripting.filesystemobject")
if not fso.FileExists(strSourceFile) then
fso.CreateTextFile strSourceFile
set fff=fso.GetFile(strSourceFile)
set mmm=fff.openastextstream(2)
mmm.write "<?xml version=""1.0"" encoding=""gb2312"" ?>" & vbcrlf & "<" & rootnode & ">" & vbcrlf & "<" & snode & ">" & vbcrlf & "</" & snode & ">" & vbcrlf & "</" & rootnode & ">"
set mmm=nothing
set fff=nothing
else
Response.Write("文件名冲突!")
Response.End
end if
set fso=nothing
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(server.mappath(xfolder & "/" & tname2))
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
set et=xd.documentElement
set cnode=xd.createElement(snode)
et.appendchild(cnode)
set node2=xd.createElement("name")
node2.text=biaoti
cnode.appendchild(node2)
set node2=xd.createElement("index")
node2.text=f
cnode.appendchild(node2)
xd.save server.mappath(xfolder & "/" & tname2)
set cnode=nothing
set node2=nothing
set xd=nothing
set xd=server.CreateObject("msxml2.domdocument")
xd.load(server.mappath(xfolder & "/" & filen))
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
set cnode=xd.selectSingleNode("//" & rootnode & "/" & snode)
set node2=xd.createElement("name")
node2.text=biaoti
cnode.appendchild(node2)
set node2=xd.createElement("content")
node2.text=neirong
cnode.appendchild(node2)
xd.save server.mappath(xfolder & "/" & filen)
set node2=nothing
set cnode=nothing
set xd=nothing
if err=0 then
Response.Redirect "add.asp?tt=录入成功!"
else
Response.Redirect "add.asp?tt=录入失败!"
end if
%>
<center><p><!--<span style="cursor:hand;color:ff0000" >--><a href="add.asp">录入下一个文件</a> </p></center>
</BODY>
</HTML>
3 . 配置文件(config.asp)
< %
tname="index.xml"
xfolder="xml"
tname2="flfgcx_list.xml"
cname="法律法规查询"
rootNode="flfg"
sNode="flfgcx"
% >
4 . 主界面(main.asp)
<!--#include file="config.asp"-->
<!--#include file="../conn.asp"-->
<%...'Response.Redirect "show2.asp" '如果只显示一条,久把注释去掉%>
<html>
<head>
<title>工会网</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
A {text-decoration:none}
A:link {text-decoration: none; font-family: }
A:visited {text-decoration: none; font-family: }
A:active {text-decoration: none; font-family: }
A:hover {text-decoration: underline; }
</style>
</head>
<body>
<div align="center">
<table width="760" bgcolor="#DEF342" border="0" cellspacing="0" cellpadding="0" height="306">
<tr>
<td height="22" colspan="3" background="../images/web040.jpg"> </td>
</tr>
<tr>
<td colspan="3" height="152"><img src="USET.jpg" width="760" height="150"></td>
</tr>
<tr>
<td height="22" colspan="3" background="../images/web040.jpg"> </td>
</tr>
<tr height=4><td colspan=3></td></tr>
<tr>
<td height="50" colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#DEF342">
<tr>
<td ><span style="font-size:<%=font_size2%>"> 您现在的位置: > <a style="font-size:<%=font_size2%>" href="<%=Mainfolder%>/<%=MainPage%>">长客工会网</a>
> <span style='color:#FF0000'><%=cname%></span></span><br><br>
<!-- <p align="center"><b><font size="4"><%=cname%></font></b></p>-->
<table border="0" frame="box" rules="none" cellspacing="0" cellpadding="4" width="85%" align="center">
<tr><td>
<%...
strSourceFile = Server.MapPath(xfolder & "/" & tname2)
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(strSourceFile)
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
rows=1
firstrow=true
for i=0 to xd.childNodes(1).childNodes.length-1
%>
<tr
<%
if firstrow=true then
firstrow=false
Response.Write " height=20 "
end if
%>><td valign=bottom style='font-size:13;width:88.42%;
<%if rows=1 then%>
background:#FFFFCC
<%... rows=2
else
rows=1%>
background:#ffccff
<%...end if%>
' bgcolor="#0000FF"> <span style="font-size:12;color:eeee88"> ◆</span><a href="show.asp?f=<%=trim(xd.childNodes(1).childNodes(i).childNodes(1).text)%>&n=<%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%>" target="_blank" style="font-size:<%=font_size%>"> <%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%></a></td>
</tr>
<!--<tr height=1 bgcolor=bbbbbb><td></td></tr>-->
<%...
next%>
<tr height=30><td></td></tr>
<%...set xd=nothing%>
</table>
<p align="center"><a href="<%=Mainfolder%>/<%=MainPage%>"><img src="home.jpg"></a></p></td>
</tr> <tr><td> </td></tr>
</table></td>
</tr>
<tr bgcolor="#999999">
<td height="3" colspan="3"></td>
</tr>
<tr bgcolor="white"><td> </td></tr>
<tr bgcolor="white">
<td colspan="3"><!--#include file=../config/footer.htm --></td>
</tr>
<tr bgcolor="white"><td> </td></tr>
</table>
</div>
</body>
</html>
5 . 修改界面(xiugai.asp)
<%...@ Language=VBScript %>
<!--#include file="config.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY><center><h3><%=cname%>修改界面</h3></center>
<%...
f=Request.QueryString("f")
n=Request.QueryString("n")
filen=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & filen)
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(strSourceFile)
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
if not xd.hasChildNodes() then
Response.Write("为找到指定的数据!")
Response.End
end if
%>
<form action="xiugai_ok.asp" method="post" name="form1" target="_blank">
<table border="1" cellpadding="0" cellspacing="0" width="500" align="center" bordercolor="black" bgcolor="#c4f578" style="border-collapse:collapse">
<input type="hidden" name="id" value="<%=f%>"></td>
<tr>
<td width="150">文件名</td>
<td width="350"><%=filen%></td>
</tr>
<tr>
<td width="150">标题</td>
<td width="390"><textarea name="title" rows=10 cols=80><%=xd.childNodes(1).childNodes(0).childNodes(0).text%></textarea></td>
</tr>
<tr>
<td width="150">内容</td>
<td width="390"><textarea name="neirong" rows=10 cols=80><%=xd.childNodes(1).childNodes(0).childNodes(1).text%></textarea></td>
</tr>
<tr >
<td colspan="8"><p align="center"><input type="submit" value="提交" name="button1"><input type=button value="关闭" ></p></td>
</tr>
</table>
<br><br>
</form>
<%...set xd=nothing%>
</BODY>
</HTML>
6 . 修改提交(xiugai_ok.asp)
<%...@ Language=VBScript %>
<!--#include file="config.asp"-->
<%...
f=trim(Request("id"))
biaoti=Request("title")
neirong=Request("neirong")
IF biaoti="" then
Response.Write "请输入标题"
Response.End
end if
if neirong="" then
Response.Write "内容不能为空"
Response.End
end if
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(server.mappath(xfolder & "/" & tname2))
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
sql="//" & rootnode & "/" & snode & "[index=" & f & "]"
set node2=xd.selectSingleNode(sql)
node2.childnodes(0).text=biaoti
xd.save server.mappath(xfolder & "/" & tname2)
set node2=nothing
set xd=nothing
filen=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & filen)
set xd2=server.CreateObject("msxml2.domdocument")
xd2.load(strSourceFile)
if xd2.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
xd2.childNodes(1).childNodes(0).childNodes(0).text=biaoti
xd2.childNodes(1).childNodes(0).childNodes(1).text=neirong
xd2.save strSourceFile
set node2=nothing
set xd2=nothing
%>
<script language="javascript">...
window.close();
</script>
7 . 删除信息 (del.asp)
<%...@ Language=VBScript %>
<!--#include file="../conn.asp"-->
<%...
f=Request("f")
n=request("n")
IF f="" or n="" then
Response.Write "参数故障!"
Response.End
end if
filen=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & filen)
set fso=server.CreateObject("scripting.filesystemobject")
if(fso.FileExists(strSourceFile)) then fso.DeleteFile strSourceFile
set fso=nothing
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(server.mappath(xfolder & "/" & tname2))
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
set et=xd.documentElement
sql="//" & rootnode & "/" & snode & "[name='" & n & "' && index=" & f & "]"
set node2=xd.selectSingleNode(sql)
et.removeChild(node2)
xd.save server.mappath(xfolder & "/" & tname2)
set node2=nothing
set xd=nothing
Response.Redirect firstPage
%>
8 . 维护界面主界面 (default.asp)
<%...@ Language=VBScript %>
<!--#include file="config.asp"-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<style>...
td{...}{font-size:13;word-wrap:break-word}
</style>
</HEAD>
<BODY>
<%...strSourceFile = Server.MapPath(xfolder & "/" & tname2)
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(strSourceFile)
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
'set tnode=xd.childNodes(1)
%>
<table border="1" cellpadding="0" cellspacing="0" align="center" bordercolor="black" width="760" bgcolor="#c4f578" style="border-collapse:collapse">
<tr><td style="font-size:24;font-weight:bold" align=center colspan="<%=4%>"><%=cname%></td></tr>
<tr height=30><td style="font-size:13;color:ff0000" colspan="<%=4%>" align=left>目前总记录数:<%=xd.childNodes(1).childNodes.length%> <a href="add.asp" target="_blank" style="color:0000ff;font-weight:bold">进入录入界面</a></td></tr>
<tr height="20" bgcolor="dddddd">
<td width="200" align="center"><%=xd.childNodes(1).childnodes(0).childnodes(0).nodename%></td>
<td width="40" align="center"><%=xd.childNodes(1).childnodes(0).childnodes(1).nodename%></td>
<td width="60" colspan=2>操作</td>
</tr>
<%... for i=0 to xd.childNodes(1).childnodes.length-1 %>
<tr >
<td><a href="show.asp?f=<%=trim(xd.childNodes(1).childNodes(i).childNodes(1).text)%>&n=<%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%>" target="_blank"><font color="blue" size="2"> <%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%></a></font></td>
<td ><%=trim(xd.childNodes(1).childNodes(i).childNodes(1).text)%></td>
<td width="30"><a href="del.asp?f=<%=trim(xd.childNodes(1).childNodes(i).childNodes(1).text)%>&n=<%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%>" >删除</a></td>
<td width="30"><a href="xiugai.asp?f=<%=trim(xd.childNodes(1).childNodes(i).childNodes(1).text)%>&n=<%=trim(xd.childNodes(1).childNodes(i).childNodes(0).text)%>" target="_blank">修改</a></td>
<%...
next
%>
<%...set xd=nothing%>
</tr>
</table>
</BODY>
</HTML>
9 . 显示详细界面(show.asp)
<%...@LANGUAGE="VBSCRIPT" CODEPAGE="CP_ACP"%>
<!--#include file="config.asp"-->
<html>
<head>
<title>工会网</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body>
<div align="center" width=760 style="width:760;word-wrap:break-word">
<table width="760" bgcolor="#DEF342" border="0" style="width:760" cellspacing="0" cellpadding="0">
<tr>
<td height="22" width="760" colspan="3" background="../images/web040.jpg"> </td>
</tr>
<tr>
<td colspan="3" width="760" height="152"><img src="USET.jpg" width="760" height="150"></td>
</tr>
<tr>
<td height="22" width="760" colspan="3" background="../images/web040.jpg"> </td>
</tr>
<tr height=4><td colspan=3></td></tr>
<tr>
<td height="50" width="760" colspan="3">
<table width="760" style="width:760" border="0" cellspacing="0" cellpadding="0" bgcolor="#DEF342">
<tr>
<td width=760><span style="font-size:<%=font_size2%>"> 您现在的位置: > <a style="font-size:<%=font_size2%>" href="<%=Mainfolder%>/<%=MainPage%>">长客工会网</a>
> <span style='color:#FF0000'><%=cname%></span></span><br><br>
<tr><td width=760>
<table border="0" cellpadding="0" cellspacing="0" width="720" align="center">
<%...
f=Request.QueryString("f")
n=Request.QueryString("n")
f=f & ".xml"
strSourceFile = Server.MapPath(xfolder & "/" & f)
Set xd = Server.CreateObject("msxml2.domdocument")
xd.async = false
xd.load(strSourceFile)
if xd.parseError.errorcode<>0 then
Response.Write("载入xml文件出错!")
Response.End()
end if
%>
<br>
<tr><td width="760">
<p align="center" height=30><b><span style="font-size:<%=font_size3%>"><%=trim(n)%></span></b></p><br>
</td></tr>
<tr><td style="word-wrap:break-word;width:720" width=720 align=left>
<%...
'for i=0 to xd.childNodes(1).childNodes.length-1
if xd.childNodes(1).childNodes.length>0 then
if xd.childNodes(1).childNodes(0).childNodes.length>0 then
if xd.childNodes(1).childNodes(i).childNodes(0).text=n then
cont=xd.childNodes(1).childNodes(i).childNodes(1).text
%>
<pre><div style="position:absolute;width:760;word-wrap:break-word;left:10;font-size:<%=font_size%>;background-color:#DEF342" align=center><div style="width:720" align=left><%=cont%> </div>
<br><p align="center"><a href="<%=Mainfolder%>/<%=MainPage%>"><img src="home.jpg"></a></p>
<table cellpadding=0 cellspacing=0 width=100% bgcolor=ffffff>
<tr height=3 bgcolor=aaaaaa><td></td></tr>
<tr height=10><td></td></tr>
<tr><td><!--#include file=../config/footer.htm --></td></tr></table>
</div></pre>
<%... end if
end if
end if
'next%>
</td></tr></table> </td></tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>