日期:2014-05-17  浏览次数:20386 次

求这种XML数据怎么绑定
XML数据:
XML code

<?xml version="1.0" encoding="utf-8"?>
<world>
<continet text="南美洲">
      <country>哥伦比亚</country>
      <country>委内瑞拉</country>
      <country>圭亚那</country>
      <country>法属圭亚那</country>
      <country>苏里南</country>
      <country>厄瓜多尔</country>
      <country>秘鲁</country>
      <country>玻利维亚</country>
      <country>巴西</country>
      <country>智利</country>
      <country>阿根廷</country>
      <country>乌拉圭</country>
      <country>巴拉圭</country>
  </continet>
</world>


我想将这个XML文档做为一个数据源绑定给repeater显示里面的国家名称(不显示洲名称),在网上找了很多方法后还是没有实现,求解。。。。

------解决方案--------------------
http://www.cnblogs.com/smhy8187/articles/1010906.html
这个不是挺详细的?或者你不嫌麻烦先将xml转换成datatable再绑定- -
------解决方案--------------------
C# code
 string strXmlFile = Server.MapPath("test.xml");
           
            DataSet ds = new DataSet();
            ds.ReadXml(strXmlFile);
            GridView1.DataSource = ds.Tables[1];
            GridView1.DataBind();

------解决方案--------------------

HTML code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Repeater ID="Repeater1" runat="server" >
            <ItemTemplate>
                <%# ((System.Xml.XmlNode)Container.DataItem).InnerText%>
            </ItemTemplate>
        </asp:Repeater>       
    </div>
    </form>
</body>
</html>