已解决问题
谷歌healthgxl用户在2014.01.05提交了关于“比亚迪f3asp操作xml”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-11-14T13:14:01。希望大家能够帮助她。详细问题描述及疑问:期待您的答案,你是我的宝贝,你是我的花,谢谢你对我的帮助!
详细问题描述及疑问:期待您的答案,你是我的宝贝,你是我的花,谢谢你对我的帮助!
增加、删除、修改“XML记录”
"XML文件
<?xmlversion="1.0"encoding="gb2312"?>
<stocksd
<stock>
<code>111</cod
<name>AAA</na
<openprice>7.93</openpric
<currentpr
<tradeamou
<tota
<status>1</status>
</stock>
<stock>
<code>222</code>
<name>**B</name>
<openpr
<currentprice>170.92</currentpri
<tradeamount>0</tradeamount>
<totalamount>100000</totalamount>
<s
</stock>
<stock>
<c
<name>CCC</name>
<o
<currentpric
<tradeamount>0</tradeamount>
<t
<status>1</status></stock>
</stocks>
"处理文件Stoc
<%
Response.CacheControl="no-cache"
%>
<html>
<head>
<title>XML的股票行情</t
<style>
td{f
</style>
</head>
<body>
<h1>XML的股
<hr>
<%
setxml=Server.
"setx
xml.loa
if
Respo
Response.Write"x
Response.Write"xml.parseError
Response.End
endif
"如果<stocks>的DATE属性不是今天,则改为今天
xml
ifdatediff("d",xmlDate,date)>=1then
"xml.documentElem
""可以在此加入改变股票价格的代码
i=1
St
setStockList=xml.getEleme
fori=0toStockAmoun
setSto
ra
s
ifrnd(
randomize
StockTemp.childNodes.item(2).text=FormatNumber(Ccur(StockTemp.childNodes.item(2).text)*(1+ss*rnd()/10),2)
StockTemp.childNodes.item(3).text=StockTemp.childNodes.item(2).text
next
***.s**eServer.MapPath("stocks.xml")
endif
ifRequest.Form("submit")="增加股票"then
setobjRoot=xml.documentElement
setnewStock=xml.createElement("stock")
objRoot.appendChildnewStock
setobjA1=xml.createElement("code")
newStock.appendChildobjA1
objA1.text=Request.Form("scode")
setobjA2=xml.createElement("name")
newStock.appendChildobjA2
objA2.text=Request.Form("sname")
setobjA3=xml.createElement("openprice")
newStock.appendChildobjA3
objA3.text=Request.Form("openPrice")
setobjA4=xml.createElement("currentprice")
newStock.appendChildobjA4
objA4.text=Request.Form("curPrice")
setobjA5=xml.createElement("tradeamount")
newStock.appendChildobjA5
objA5.text=Request.Form("tradeAmount")
setobjA6=xml.createElement("totalamount")
newStock.appendChildobjA6
objA6.text=Request.Form("TotalAmount")
setobjA7=xml.createElement("status")
newStock.appendChildobjA7
objA7.text=Request.Form("status")
***.s**eServer.MapPath("stocks.xml")
setnewStock=nothing
setobjRoot=nothing
setobjA1=nothing
setobjA2=nothing
setobjA3=nothing
setobjA4=nothing
setobjA5=nothing
setobjA6=nothing
setobjA7=nothing
endif
ifRequest.Form("submit")="删除"andRequest.Form("remove")<>emptythen
setobjCodeList=xml.getElementsByTagName("code")
remove=split(Request.Form("remove"))
fori=0toubound(remove)
forj=0toobjCodeList.Length-1
ifobjcodeList.item(j).text=remove(i)then
xml.documentElement.removeChild(objcodeList.item(j).parentNode)
endif
next
***.s**eServer.MapPath("stocks.xml")
next
endif
"***.s**eServer.MapPath("stocks.xml")
Response.WriteFormatDateTime(now)
%>
<hr>
<formaction=""method="post">
<TABLEcellSpacing=1cellPadding=1width="100%"border=1>
<TR>
<TD>股票代码</TD>
<TD>股票名称</TD>
<TD>开盘价格</TD>
<TD>当前价格</TD>
<TD>成交量</TD>
<TD>流通总数</TD>
<TD>状态</TD>
<TD>删除</TD>
</TR>
<%
i=1
StockAmount=xml.getElementsByTagName("stock").length
setStockList=xml.getElementsByTagName("stock")
fori=0toStockAmount-1
setStockTemp=StockList.item(i)
%>
<TR>
<TD><%=StockTemp.childNodes.item(0).text%></TD>
<TD><%=StockTemp.childNodes.item(1).text%></TD>
<TD><%=StockTemp.childNodes.item(2).text%></TD>
<TD><%=StockTemp.childNodes.item(3).text%></TD>
<TD><%=StockTemp.childNodes.item(4).text%></TD>
<TD><%=StockTemp.childNodes.item(5).text%></TD>
<TD><%=StockTemp.childNodes.item(6).text%></TD>
<TD><inputtype="checkbox"name="remove"value=<%=StockTemp.childNodes.item(0).text%>></TD>
</TR>
<%
next
setxml=nothing
%>
<TR>
<TD><inputtype="text"name="scode"></TD>
<TD><inputtype="text"name="sname"></TD>
<TD><inputtype="text"name="openPrice"size="6"></TD>
<TD><inputtype="text"name="curPrice"size="6"></TD>
<TD><inputtype="text"name="tradeAmount"></TD>
<TD><inputtype="text"name="TotalAmount"></TD>
<TD><inputtype="text"name="status"size="6"></TD>
<TD><inputtype="submit"name="submit"value="删除"></TD>
</TR>
</TABLE>
<%
%>
<inputtype="submit"name="submit"value="增加股票">
</form>
</body>
</html>