/// <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);
}