中易网

如何从SQL数据库中读取数据并保存到XML文件中

答案:3  悬赏:70  
解决时间 2021-04-28 00:15

从SQL中读取数据并保存到XML文件中,给个例子#99

最佳答案

用asp读取数据库SQL


保存到HTML,试试导出行不

全部回答
public void updateXml(string quyu)    {    XmlDocument document = new XmlDocument();    DataSet ds=flash.quyuSearch(quyu);    string text = null;    int count = ds.Tables[0].Rows.Count;    for(int i=0;i<count;i++)    {    text+="<item item_url="+"'admin/upLoad/"+ds.Tables[0].Rows[i]["imgUrl"].ToString()+"'"+" link="+"'http://"+ds.Tables[0].Rows[i]["link"].ToString()+"'"+" />";    }    text = text.Replace("&","&amp;");    document.LoadXml(@"<bcaster>" + text + "</bcaster>");    string path = "~/flash/" + quyu + ".xml";    document.Save(HttpContext.Current.Server.MapPath(path));    ds.Dispose(); ds = null;    }
asp的 <!--#include file="conn.asp"--> <% Dim sSQL dim rs dim sCrLf dim sXmlClear dim sRssHead dim sRssEnd sCrLf = chr(13)&chr(10) '回车+换行 sXmlClear = sXmlClear & "<?xml version='1.0' encoding='GB2312'?>" & sCrLf sRssHead = "<rss version='2.0'>" & sCrLf sRssHead = sRssHead & "<channel>" & sCrLf sRssHead = sRssHead & "<title> Hi </title>" & sCrLf sRssHead = sRssHead & "<description>Look</description>" & sCrLf sRssHead = sRssHead & "<link>See It</link>" & sCrLf sRssHead = sRssHead & "<language>zh-cn</language>" & sCrLf sRssHead = sRssHead & "<docs>Why100000.COM News Center</docs>" & sCrLf sRssHead = sRssHead & "<generator>Rss Generator By WWW.shangyusoft.COM</generator>" & sCrLf sRssEnd = "</channel></rss>" Response.CharSet="gb2312" '数据集 Response.ContentType="text/xml" '数据流格式定义 '输出: Response.write sXmlClear Response.write sRssHead OpenData sSQL="select * from c_news" Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sSQL, Conn,1,1 if not (rs.eof and rs.bof) then do while not rs.eof listinfo=listinfo & "<item>" & sCrLf listinfo=listinfo &"<title> " & rs("c_title") & " </title>" & sCrLf listinfo=listinfo &"<link> " & " http://www.shangyusoft.com/" & rs("c_content") & " </link>" & sCrLf listinfo=listinfo &"<author> " & rs("c_relation") & " </author>" & sCrLf listinfo=listinfo &"<pubDate> " & rs("c_time") & " </pubDate>" & sCrLf listinfo=listinfo &"</item>" & sCrLf & sCrLf rs.movenext loop end if rs.close set rs=nothing Response.write sRssEnd body=sXmlClear&sRssHead&listinfo&sRssEnd writexml "A.xml",body function writexml(filename,bodytext) Set fso = Server.CreateObject("Scripting.FileSystemObject") Set fout = fso.CreateTextFile(Server.MapPath(filename),true) fout.WriteLine bodytext fout.close end function %>
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
问道师徒资助给什么
为什么get to school,go to school, go to wo
《指环王online》以后收费不?谁有内测激活码
在贵港东站有没有去南宁安吉车站的车啊
有没有什么无病毒的网站可以免费下载国际音标
手机QQ音乐的主要有什么功能
红苹果美术用品在哪里啊,我有事要去这个地方
李教师计算机上安装了①Visual Basic;②OCR
周杰伦的个人资料谁知道啊?
元素最高价氧化物对应水化物指的是什么?请举
求植树节手抄报(带图片)名字有创意一点,越
完美世界国际版的,可以改名么
为什么 我的男友 不喜欢吃水果 是不是男人都
诺基亚6202c的主题和哪种手机型号通用???
北潭堡地址在哪,我要去那里办事
推荐资讯
曹县魏湾便民家电地址在哪,我要去那里办事
一梦千年不觉晓这本书完结了吗?
我能把戒指带在你的手上吗?
我在观兰镇库坑怎么去观兰镇大水坑二村 要怎
手机上QQ反映慢怎么办?
你怕打针,还是输液呢!
一本故事书有80页,分三天看完,第一天看了全书
联想Y458A-TSI(H)怎么样
福建绿美园林工程有限公司怎么去啊,有知道地
谁可以用名字我只爱许崇一个作诗啊
红枣泡水喝需要去核吗
明星用不用QQ呢?
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?