asp如何修改xml文件
xml文件如下<graphcaption='MonthlyUnitSales'xAxisName='Month'yAxisName='Units'decimalPreci...
xml文件如下
<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' decimalPrecision='0' formatNumberScale='0'>
<set name='Jan' value='462' color='AFD8F8' />
<set name='Feb' value='85753.4' color='F6BD0F' />
<set name='Mar' value='671' color='8BBA00' />
</graph>
想改value的值。用ASP.请大家帮忙 展开
<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' decimalPrecision='0' formatNumberScale='0'>
<set name='Jan' value='462' color='AFD8F8' />
<set name='Feb' value='85753.4' color='F6BD0F' />
<set name='Mar' value='671' color='8BBA00' />
</graph>
想改value的值。用ASP.请大家帮忙 展开
展开全部
你是想自己写一个XML文件么?
用fso就行了
举个例子
你的数据库存里有二个字段 title name 数据库名为 mysong
<%
sql="select title,name from mysong order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
dim fso,hf
set fso=Server.CreateObject("Scripting.FileSystemObject")
set hf=fso.CreateTextFile(Server.mappath("list.xml"),true)
hf.write "<?xml version=" & chr(34) &"1.0"&chr(34) & " encoding="&chr(34) & " GB2312"&chr(34) & " ?>" & vbcrlf
hf.write "<data>"& vbcrlf
do while not(rs.eof) and not(rs.bof)
hf.write "<song>"& vbcrlf
hf.write "<title>"& rs("title")&"</title>"& vbcrlf
hf.write "<name>"& rs("name")&"</name>"& vbcrlf
hf.write "</song>"& vbcrlf
rs.movenext
loop
rs.close
set rs=nothing
hf.write "</data>"
hf.close
set hf=nothing
set fso=nothing
%>
你懂ASP的话应该看得懂吧?
希望对你能有所帮助。
用fso就行了
举个例子
你的数据库存里有二个字段 title name 数据库名为 mysong
<%
sql="select title,name from mysong order by id desc"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
dim fso,hf
set fso=Server.CreateObject("Scripting.FileSystemObject")
set hf=fso.CreateTextFile(Server.mappath("list.xml"),true)
hf.write "<?xml version=" & chr(34) &"1.0"&chr(34) & " encoding="&chr(34) & " GB2312"&chr(34) & " ?>" & vbcrlf
hf.write "<data>"& vbcrlf
do while not(rs.eof) and not(rs.bof)
hf.write "<song>"& vbcrlf
hf.write "<title>"& rs("title")&"</title>"& vbcrlf
hf.write "<name>"& rs("name")&"</name>"& vbcrlf
hf.write "</song>"& vbcrlf
rs.movenext
loop
rs.close
set rs=nothing
hf.write "</data>"
hf.close
set hf=nothing
set fso=nothing
%>
你懂ASP的话应该看得懂吧?
希望对你能有所帮助。
追问
别复制别人的,大哥
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用FSO操作!
首先建立一个模板xml_model.inc
<song>
<title>$Title$</title>
<name>$URL$</name>
</song>
读取数据库
Set Rs=Server.CreateObject("adodb.recordset")
Rs.open("Select * from [Table]"),conn,1,1
if Rs.eof or Rs.bof then
Response.write("没有数据")
else
Dim XML,NewXML,FSO,MyFile
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set MyFile=Fso.OpenTextFile(Server.MapPath("xml_model.inc"), 1)
XML=MyFile.readAll
Do while Not(Rs.eof or Rs.bof)
NewXML=NewXML&Replace(XML,"$Title$","&Rs("title")&")
NewXML=Replace(NewXML,"$URL$","&Rs("url")&")
Rs.movenext
Loop
Fso.writeLine(NewXML)
……
end if
首先建立一个模板xml_model.inc
<song>
<title>$Title$</title>
<name>$URL$</name>
</song>
读取数据库
Set Rs=Server.CreateObject("adodb.recordset")
Rs.open("Select * from [Table]"),conn,1,1
if Rs.eof or Rs.bof then
Response.write("没有数据")
else
Dim XML,NewXML,FSO,MyFile
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set MyFile=Fso.OpenTextFile(Server.MapPath("xml_model.inc"), 1)
XML=MyFile.readAll
Do while Not(Rs.eof or Rs.bof)
NewXML=NewXML&Replace(XML,"$Title$","&Rs("title")&")
NewXML=Replace(NewXML,"$URL$","&Rs("url")&")
Rs.movenext
Loop
Fso.writeLine(NewXML)
……
end if
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询