使用GridView绑定XmlDocument对象

    技术2022-05-11  37

    < script runat  =   " server " >      protected   void  Page_Load( object  sender, EventArgs e)    {        System.Xml.XmlDocument doc  =   new  System.Xml.XmlDocument();        doc.Load( " http://dotnet.aspx.cc/Rss.aspx " );        XmlDataSourceX.Data  =  doc.InnerXml;        XmlDataSourceX.XPath  =   " /rss/channel/item " ;            } </ script > < asp:GridView  ID ="GridViewX"  runat ="server"  DataSourceID ="XmlDataSourceX"  AutoGenerateColumns ="False" >      < Columns >          < asp:TemplateField  HeaderText ="文章标题" >              < ItemTemplate >                  < asp:HyperLink  ID ="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:XmlDataSource  ID ="XmlDataSourceX"  runat ="server" ></ asp:XmlDataSource >

    最新回复(0)