使用GridView绑定XmlDocument对象的步骤
<scriptrunat="server">
protectedvoidPage_Load(objectsender,EventArgse)
{
System.Xml.XmlDocumentdoc=newSystem.Xml.XmlDocument();
doc.Load("http://dotnet.aspx.cc/Rss.aspx");
XmlDataSourceX.Data=doc.InnerXml;
XmlDataSourceX.XPath="/rss/channel/item";
}
</script>
protectedvoidPage_Load(objectsender,EventArgse)
{
System.Xml.XmlDocumentdoc=newSystem.Xml.XmlDocument();
doc.Load("http://dotnet.aspx.cc/Rss.aspx");
XmlDataSourceX.Data=doc.InnerXml;
XmlDataSourceX.XPath="/rss/channel/item";
}
</script>
<asp:GridViewID="GridViewX"runat="server"DataSourceID="XmlDataSourceX"AutoGenerateColumns="False">
<Columns>
<asp:TemplateFieldHeaderText="文章标题">
<ItemTemplate>
<asp:HyperLinkID="HyperLink1"runat="server"NavigateUrl='<%#XPath("link")%>'Target="_blank"><%#XPath("title")%>></asp:HyperLink>
[<%#(DateTime.Parse(XPath("pubDate").ToString().Replace("GMT",""))).ToString("yyyy年M月d日")%>]
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:XmlDataSourceID="XmlDataSourceX"runat="server"></asp:XmlDataSource>
<Columns>
<asp:TemplateFieldHeaderText="文章标题">
<ItemTemplate>
<asp:HyperLinkID="HyperLink1"runat="server"NavigateUrl='<%#XPath("link")%>'Target="_blank"><%#XPath("title")%>></asp:HyperLink>
[<%#(DateTime.Parse(XPath("pubDate").ToString().Replace("GMT",""))).ToString("yyyy年M月d日")%>]
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:XmlDataSourceID="XmlDataSourceX"runat="server"></asp:XmlDataSource>
本文地址:http://www.45fan.com/dnjc/70709.html