zoukankan      html  css  js  c++  java
  • asp.net 遍历xml 及 Repeater 绑定xml

    //获取xml文件
    XmlDocument xd = new XmlDocument();
    xd.LoadXml(xml);

    DisplayTree(xd.DocumentElement);

     /// <summary>
        /// 遍历整个xml函数
        /// </summary>
        /// <param name="xmlNode"></param>
        private void DisplayTree(XmlNode node)
        {
            if (node != null)  //如果不为空
            {
                 //输出xml信息
            }
            if (node.HasChildNodes)//如果该节点下有子节点
            {
                node = node.FirstChild;
                while (node != null)
                {
                    DisplayTree(node);
                    node = node.NextSibling;
                }
            }
        }

    --------------------------------------------------------------------------------------------

    Repeater 绑定xml

    XmlDocument xd = new XmlDocument();
    xd.LoadXml(xml);
    this.repXmlList.DataSource = doc.DocumentElement.ChildNodes;
    this.repXmlList.DataBind();

    <asp:Repeater ID="repXmlList" runat="server">
                <ItemTemplate>
                   <%# ((XmlNode)Container.DataItem).Attributes["name"].Value%><br />
                </ItemTemplate>
    </asp:Repeater>

    自己在应用中的一些记录吧,自己以后多写写总结什么的。

  • 相关阅读:
    python高级特性和高阶函数
    代理模式及案例
    我的报错错误记录
    摘抄-编码规范
    测试java的Lambda语法
    测试IDEA将新建项目提交到github上
    js处理科学计数法
    测试java操作运算符
    java根据模板生成,导出word和pdf(aspose.words实现word转换pdf)
    sqlserver日期函数
  • 原文地址:https://www.cnblogs.com/infozr/p/2663042.html
Copyright © 2011-2022 走看看