代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
VB.Net
】
包括生成rss.xml文件
作者:
Dezai.CN
/ 发布于
2013/2/23
/
1113
vb.net写的一个asp.net页面xml.aspx,包括生成rss.xml文件
<%@ Import Namespace=System.Xml %> <%@ Import Namespace=System.IO %> <%@ Import Namespace=System.Data %> <%@ Import Namespace=System.Data.SqlClient %> <script language=VB runat=server> public sub Page_Load(Src as Object, e as EventArgs) Dim xmlDoc as String = Server.MapPath(rss.xml) Dim writer as XmlTextWriter Dim sqlString As String Dim myConnection As SQLConnection Dim myCommand As SQLCommand Dim myDataReader As SqlDataReader Dim myConn As String = System.Configuration.ConfigurationSettings.AppSettings(Conn) Dim i_id As String Dim i_title As String Dim i_content As String Dim i_day As String sqlString = select top 10 id,i_title,i_content,i_day from information order by id desc myConnection = New SQLConnection( myConn ) myCommand = New SQLCommand( sqlString, myConnection ) myConnection.Open() myDataReader = myCommand.ExecuteReader() try writer = new XmlTextWriter(xmlDoc,Encoding.UTF8) writer.Formatting = Formatting.Indented writer.WriteStartDocument(true) writer.WriteComment(注释) writer.WriteStartElement(rss) writer.WriteAttributeString(version,0.92) writer.WriteStartElement(channel) writer.WriteStartElement(title) writer.WriteString(频道名称) writer.WriteEndElement() writer.WriteStartElement(link) writer.WriteString(http://你的网址/) writer.WriteEndElement() writer.WriteStartElement(description) writer.WriteString(最新的十条信息!) writer.WriteEndElement() writer.WriteStartElement(language) writer.WriteString(zh-cn) writer.WriteEndElement() ''''循环开始 While myDataReader.Read() i_id = myDataReader.GetInt32(0).ToString() i_title = myDataReader.GetString(1).Trim() i_content = myDataReader.GetString(2).Trim() i_day = myDataReader.GetDateTime(3).ToString() writer.WriteStartElement(item) writer.WriteStartElement(title) writer.WriteString(i_title) writer.WriteEndElement() writer.WriteStartElement(description) writer.WriteCData(left(i_content,100)) writer.WriteEndElement() writer.WriteStartElement(pubDate) writer.WriteString(i_day) writer.WriteEndElement() writer.WriteStartElement(link) writer.WriteString(http://你的网址/jnszf.aspx?id=&i_id) writer.WriteEndElement() writer.WriteEndElement() End While ''''循环结束 writer.WriteEndElement() writer.WriteEndElement() writer.Flush() writer.Close() Dim doc as XmlDocument = new XmlDocument() doc.Load(xmlDoc) Response.ContentType = text/xml doc.Save(Response.Output) catch exp as Exception Response.Write(exp.ToString()) finally if (NOT writer is Nothing) then writer.Close() end if end try myDataReader.Close() myConnection.Close() end sub </script> 相同的效果如rss.aspx页面 <%@ Import Namespace=System.Data %> <%@ Import Namespace=System.Data.SqlClient %> <script language=vb runat=server> Sub Page_Load(Sender as object,e as eventargs) Dim myConnection As SqlConnection Dim myAdapter As SqlDataAdapter Dim sqlString As String Dim myDataSet As DataSet Dim myConn As String = System.Configuration.ConfigurationSettings.AppSettings(Conn) myConnection = New SQLConnection( myConn ) sqlString = select top 10 * from information order by id desc myAdapter = New SQLDataAdapter( sqlString, myConnection ) myDataSet = New DataSet myAdapter.Fill( myDataSet, information ) Response.ContentType = Text/XML myRepeater.DataSource = myDataSet myRepeater.DataBind() End Sub </script> <?xml version=1.0 encoding=gb2312 ?> <rss version=0.92 > <channel> <title>频道名称</title> <link>http://你的网址/</link> <description>最新的十条记录</description> <language>zh-cn</language> <asp:Repeater id=myRepeater runat=server> <ItemTemplate> <item> <title><%#DataBinder.Eval(Container.DataItem,i_title)%></title> <description><![CDATA[<%#DataBinder.Eval(Container.DataItem,i_title)%>]]></description> <pubDate><%#DataBinder.Eval(Container.DataItem,i_day)%></pubDate> <link>http://你的网址/jnszf.aspx?id=<%#DataBinder.Eval(Container.DataItem, id)%></link> </item> </ItemTemplate> </asp:Repeater> </channel> </rss>
试试其它关键字
rss.xml
同语言下
.
根据User Agent来判定操作系统与浏览器类型
.
将PPT内容导出为JPG图片
.
Java屏幕截取
.
发送邮件组件
.
子窗体在父窗体指定的控件中显示
.
取文件的大小
.
从某个目录中筛选文件
.
VB脚本调用exe应用程序并传递参数
.
图像格式转换工具
.
洗牌算法
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3