zoukankan      html  css  js  c++  java
  • 从XML文件读取数据绑定到列表控件

    xml文件:
     1<?xml version="1.0" encoding="utf-8" ?>
     2<DdlFeeData>
     3    <Content>
     4        <name>总费用</name>
     5        <value>should_pay</value>
     6    </Content>
     7    <Content>
     8        <name>加工费</name>
     9        <value>process_fee</value>
    10    </Content>
    11</DdlFeeData>
    12
    代码:
     1         /// <summary>
     2         /// 从XML文件读取数据绑定到列表控件
     3         /// </summary>
     4         /// <remarks>Code by 旋律游魂</remarks>
     5         /// <param name="filepath">XML文件路径</param>
     6         /// <param name="nodeString">结点</param>
     7         /// <param name="lic">ListControl ID</param>
     8         public void ReadXMLBindListControl(string filepath,string nodePath,System.Web.UI.WebControls.ListControl lic)
     9         {
    10             lic.Items.Clear();
    11             XmlDocument doc = new XmlDocument();
    12             doc.Load(filepath);
    13             XmlNodeList nodeList = doc.SelectNodes(nodePath);
    14 
    15             foreach(XmlNode node in nodeList)
    16                 lic.Items.Add(new ListItem(node.ChildNodes[0].InnerText,node.ChildNodes[1].InnerText));
    17         }

    调用:
        ReadXMLBindListControl(Server.MapPath("DdlInfoData.xml"),"DDLInfoList/Content",DdlqueryDetail);

  • 相关阅读:
    如何提高PHP执行效率
    PHP MySQL 预处理语句
    CDN拾遗
    Rendering React components to the document body
    模拟select,隐藏下拉列表的几种实现
    前端数据范式化
    其实我们可以少写点if else和switch
    [译]the cost of javascript in 2018(1)
    provisional headers are shown 知多少
    f5到底刷新了点什么,你知道吗
  • 原文地址:https://www.cnblogs.com/wintersun/p/743375.html
Copyright © 2011-2022 走看看