从xml文件中读取出数据

1 篇文章 0 订阅

 XmlDocument doc = new XmlDocument();
 doc.Load(“C:\\Users\\mx\\Desktop\\cmr\\DTcms_40_acc_src2\\DTcms.Web\\xmlconfig\\urls.config");
 XmlNode xn = doc.SelectSingleNode("urls");

   foreach (XmlElement xe in xn.ChildNodes)
            {
                if (xe.NodeType != XmlNodeType.Comment && xe.Name.ToLower() == "rewrite")
                {
                    if (xe.Attributes["name"] != null)
                    {
                        if (!string.IsNullOrEmpty(channel))
                        {
                            if (xe.Attributes["channel"] != null && channel.ToLower() == xe.Attributes["channel"].Value.ToLower())
                            {
                                Model.url_rewrite model = new Model.url_rewrite();
                                if (xe.Attributes["name"] != null)
                                    model.name = xe.Attributes["name"].Value;

                                foreach (XmlElement xe1 in xe.ChildNodes)
                                {
                                    if (xe1.NodeType != XmlNodeType.Comment && xe1.Name.ToLower() == "item")
                                    {

 

 

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

<?xml version="1.0" encoding="utf-8"?>
<urls>
  <rewrite name="index" type="index" page="index.aspx" inherit="DTcms.Web.UI.Page.index" templet="index.html">
    <item path="index.aspx" pattern="index.aspx" />
  </rewrite>
  <rewrite name="search" type="other" page="search.aspx" inherit="DTcms.Web.UI.Page.search" templet="search.html" />
  <rewrite name="usercenter" type="other" page="usercenter.aspx" inherit="DTcms.Web.UI.Page.usercenter" templet="usercenter.html">
    <item path="user/center/{0}.aspx" pattern="user/center/(\w+).aspx" querystring="action=$1" />
  </rewrite>
</urls>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值