从XML文件读取数据绑定到列表控件

xml文件:
 1 None.gif <? xml version="1.0" encoding="utf-8"  ?>
 2 None.gif < DdlFeeData >
 3 None.gif     < Content >
 4 None.gif         < name > 总费用 </ name >
 5 None.gif         < value > should_pay </ value >
 6 None.gif     </ Content >
 7 None.gif     < Content >
 8 None.gif         < name > 加工费 </ name >
 9 None.gif         < value > process_fee </ value >
10 None.gif     </ Content >
11 None.gif </ DdlFeeData >
12 None.gif
代码:
 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);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值