Linq to XML 排序,分页,多节点查询数据

/// <summary>
        /// 根据
        /// 获取团购的开发API文件
        /// </summary>
        /// ///APIUrl:地址
        /// pageIndex:当前页数
        /// 针对好百度格式规范
        ///
        public void getTeamApiXML(List<string> XMLPath)
        {
           
            string path = null;
            for (int i = 0; i < XMLPath.Count(); i++)
            {
                path = XMLPath[i];

                XDocument doc = XDocument.Load(path);

                //查询
                var linq = from m in doc.Descendants("url").Take(54)
                           //按价格排序方法
                           //let price = (string)m.Element("price")
                           //orderby price  //          //  where M.Element("title").Value.Equals("")
                           select new
                           {
                               //商品地址
                               Loc = m.Element("loc").Value,
                               //团购网名字
                               Website= m.Element("data").Element("display").Element("website").Value,
                              
                               //团店铺
                               siteurl = m.Element("data").Element("display").Element("siteurl").Value,
                               商品的描述
                               Title = getStringTitle(m.Element("data").Element("display").Element("title").Value),
                               //图片
                               Image = m.Element("data").Element("display").Element("image").Value,
                               //原价
                               Value = m.Element("data").Element("display").Element("value").Value,
                               现价
                               Price = m.Element("data").Element("display").Element("price").Value,
                               折扣
                               Rebate = m.Element("data").Element("display").Element("rebate").Value,
                               //购买人数
                               Bought = m.Element("data").Element("display").Element("bought").Value

                           };

                TeamByModel tbm;
                // 封装成实体
                foreach (var item in linq)
                {
                    tbm = new TeamByModel();
                    tbm.website = item.Website;
                    tbm.siteurl = item.siteurl;
                    tbm.title = item.Title;
                    tbm.image = item.Image;
                    tbm.value = item.Value;
                    tbm.price = item.Price;
                    tbm.rebate = item.Rebate;
                    tbm.bought = item.Bought;
                    tbm.Loc = item.Loc;
                   //添加到list
                    lquery.Add(tbm);

                }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值