xmlfile1.xml
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<xinwen>
<news>
<news_id>1</news_id>
<news_title>上海国际艺术节开幕</news_title>
<news_author>王建宁</news_author>
<news_ly>原创</news_ly>
<news_content>第十三届中国上海国际艺术节将于11月18日举办。</news_content>
<news_adddate>2013-10-18</news_adddate>
</news>
<news>
<news_id>2</news_id>
<news_title>上海首批公租房下月起招租</news_title>
<news_author>王水宁</news_author>
<news_ly>转载</news_ly>
<news_content>两小区分别位于徐汇华庭和上体馆附近。</news_content>
<news_adddate>2013-10-18</news_adddate>
</news>
</xinwen>
webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test15_8.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" DataSourceID="XmlDataSource1" ForeColor="Black" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="编号">
<ItemTemplate><%# XPath("news_id") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="标题">
<ItemTemplate><%# XPath("news_title") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="作者">
<ItemTemplate><%# XPath("news_author") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="类别">
<ItemTemplate><%# XPath("news_ly") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="内容">
<ItemTemplate><%# XPath("news_content") %></ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="时间">
<ItemTemplate><%# XPath("news_adddate") %></ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCCCC" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
<RowStyle BackColor="White" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="Gray" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#383838" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile1.xml"></asp:XmlDataSource>
</div>
</form>
</body>
</html>