当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > asp+ 利用数据绑定来处理XML文件

ASP.NET
在word中如何控制graph控件
把一个int数组的数字从小到大排列(C#)
Asp组件高级入门与精通系列之三
连接MYSQL数据库的方法及示例
SharePoint Portal Server之常见问题
软件开发中运用到的编号
VB程序员眼中的C#7
公农历转换VB类
VB程序员眼中的C#6
优化VB.NET应用程序的性能1
C#初学乍练-文本替换工具命令行版
如何得到某集合的所有子集合
VB程序员眼中的C#3
Shared Source CLI Essentials第一章第二部分
在ASP.NET使用javascript的一点小技巧
用户 'NT AUTHORITY\NETWORK SERVICE' 登录失败解决方法
开始使用SQLServer2005,没用过MSDE,一开始还不知道怎么下手呢,呵呵
我的ASP.net学习历程有关于.dll文件的迷惑
在图片上写字 C#
Shared Source CLI Essentials第一章第一部分

ASP.NET 中的 asp+ 利用数据绑定来处理XML文件


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 70 ::
收藏到网摘: n/a

/*
豆腐制作 都是精品
http://www.asp888.net 豆腐技术站
如转载 请保留版权信息
*/
test.aspx 是主运行程序 site.xml 是包含有数据的xml 文件

<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Data" %>

<html>
<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
'http://www.asp888.net
Dim DS As New DataSet
Dim FS As FileStream
Dim Reader As StreamReader

FS = New FileStream(Server.MapPath("site.xml"),FileMode.Open,FileAccess.Read)
Reader = New StreamReader(FS)
DS.ReadXml(Reader)
FS.Close()
Dim Source As DataView
Source = new DataView(ds.Tables(0))
MyDataGrid.DataSource = Source
MyDataGrid.DataBind()
End Sub
</script>

<body>

<h3><font face="Verdana">技术站点一览</font> <span runat="server" id="MySpan"/></h3>

<ASP:DataGrid id="MyDataGrid" runat="server"
Width="800"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
>
<property name="Columns">
<asp:HyperLinkColumn
DataNavigateUrlField="url"
DataNavigateUrlFormatString={0}
Text="参观!"
/>
</property>
</ASP:DataGrid>


</body>
</html>

site.xml 文件的内容

<root>
<schema id="allsite" targetNamespace="" xmlns="http://www.w3.org/1999/XMLSchema" xmlns:xdo="urn:schemas-microsoft-com:xml-xdo" xdo:DataSetName="books">
<element name="sites">
<complexType content="elementOnly">
<element name="url" type="string" minOccurs="1" allownull=""></element>
<element name="site" type="string" minOccurs="1"></element>
<element name="content" type="string" minOccurs="0" maxoccurs="1"></element>
</complexType>
</element>
</schema>

<allsite>
<sites>
<url>http://www.asp888.net</url>
<site>豆腐</site>
<content>豆腐制作 都是精品</content>
</sites>
</allsite>

</root>

作者:豆腐