zoukankan      html  css  js  c++  java
  • linq to XML与拉姆达表达式

    <?xml version="1.0" encoding="utf-8" ?>
    <traderates_get_response>
      <trade_rates list="true">
        <trade_rate>
          <num_iid>18142814168</num_iid>
          <content>很好,很仙的一双鞋子发货很快,周末不出门就收到了宝贝</content>
          <created>2013-05-21 10:51:51</created>
          <item_price>165.0</item_price>
          <item_title>聚 星期六 新款女鞋正品羊皮坡跟花朵女鞋凉鞋 SS22S51008</item_title>
          <nick>zhangxiaohuaddd0817</nick>
          <oid>220412664589661</oid>
          <rated_nick>454545声威大震<rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>220412664589661</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>19578379478</num_iid>
          <content>好漂亮!!!</content>
          <created>2013-05-21 10:26:22</created>
          <item_price>748.0</item_price>
          <item_title>聚 星期六正品2013新春款羊皮高跟撞色鱼嘴花朵女单鞋SS31D13120</item_title>
          <nick>飘落的雪花314</nick>
          <oid>220384811871815</oid>
          <rated_nick>星sdsdddddd<rated_nick_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>220384811871815</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>18142814168</num_iid>
          <content>穿起来挺舒服的,粉色很漂亮不亏是大牌,这次EMS也给力,两天就到了!</content>
          <created>2013-05-21 10:23:46</created>
          <item_price>790.0</item_price>
          <item_title>聚 星期六 新款女鞋正品羊皮坡跟花朵女鞋凉鞋 SS22S51008</item_title>
          <nick>joy60ddfd3608</nick>
          <oid>348857887162352</oid>
          <rated_nick>dgsdgsgsdg店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>348857887162352</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>24023612271</num_iid>
          <content>好评!</content>
          <created>2013-05-21 10:21:44</created>
          <item_price>788.0</item_price>
          <item_title>聚 星期六2013夏季新款牛皮中跟色拼坡跟金属凉鞋女鞋SS32S5G6U4</item_title>
          <nick>ycgdd699557</nick>
          <oid>260611755791847</oid>
          <rated_nick>星期dfddfd店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>260611755791847</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>23357208982</num_iid>
          <content>好评!</content>
          <created>2013-05-21 10:21:31</created>
          <item_price>349.0</item_price>
          <item_title>聚 ST&SAT星期六2013年新品春夏款羊皮高跟凉鞋女鞋SS32S5V452</item_title>
          <nick>mspaddnhj</nick>
          <oid>260790311336881</oid>
          <rated_nick>dfdgfxsdgsdfg店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>260790311336881</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>17652186648</num_iid>
          <content>一天到货,超级给力。好评。</content>
          <created>2013-05-21 10:17:13</created>
          <item_price>688.0</item_price>
          <item_title>聚 星期六2013新款春夏款漆皮牛皮高跟撞色拼女凉鞋SS32S5B94V</item_title>
          <nick>三彪sdfsdf的生活</nick>
          <oid>221111579436676</oid>
          <rated_nick>sdgsdgsdgsdgfsd</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>221111579436676</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>18142814168</num_iid>
          <content>好评!</content>
          <created>2013-05-21 10:09:23</created>
          <item_price>790.0</item_price>
          <item_title>聚 星期六 新款女鞋正品羊皮坡跟花朵女鞋凉鞋 SS22S51008</item_title>
          <nick>sdfsdf鲜fan</nick>
          <oid>260677278637167</oid>
          <rated_nick>星sdfsdf旗舰店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>260677278637167</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <trade_rate>
          <num_iid>18020137146</num_iid>
          <content>每次买你家的鞋子都特别满意。尺码特别正,一般从网上买鞋 就怕尺码不对,但是在你家买了好几次尺码都正合适!这双鞋很美貌  颜色很亮,和我的新包很配 满意!全部五颗星!</content>
          <created>2013-05-21 10:04:34</created>
          <item_price>698.0</item_price>
          <item_title>聚 星期六2013新品春夏款牛漆皮高跟撞色拼粗跟女凉鞋SS32S599HK</item_title>
          <nick>pedsdfiyurong</nick>
          <oid>349047641968688</oid>
          <rated_nick>sdgsdgvgg店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>349047641968688</tid>
          <valid_score>true</valid_score>
        </trade_rate>
        <total_results>1500</total_results>
    </traderates_get_response>
    <!--top049126.cm4-->


    XElement xe = XElement.Parse(rsp).Element("trade_rates"); IEnumerable<XElement> item = xe.Elements("trade_rate"); foreach (XElement items in item) {
    //var pp = from b in items.Elements() where (t=>t.va) select b;
    //items的内容
      <trade_rate>
          <num_iid>18020137146</num_iid>
          <content>每次买你家的鞋子都特别满意。尺码特别正,一般从网上买鞋 就怕尺码不对,但是在你家买了好几次尺码都正合适!这双鞋很美貌  颜色很亮,和我的新包很配 满意!全部五颗星!</content>
          <created>2013-05-21 10:04:34</created>
          <item_price>698.0</item_price>
          <item_title>聚 星期六2013新品春夏款牛漆皮高跟撞色拼粗跟女凉鞋SS32S599HK</item_title>
          <nick>pedsdfiyurong</nick>
          <oid>349047641968688</oid>
          <rated_nick>sdgsdgvgg店</rated_nick>
          <result>good</result>
          <role>buyer</role>
          <tid>349047641968688</tid>
          <valid_score>true</valid_score>
        </trade_rate>
                    //获取当前XML节点下有几个tid子节点
                    int count = items.Elements().Where(t => t.Name=="tid").ToList().Count;
    
                    //获取当前XML节点名称包括id的子节点的count
                    var pp = items.Elements().Where(t => t.Name.ToString().Contains("id")).ToList().Count;
    
                    //下面则是获取XML节点名称包括id的子节点的集合
                    IEnumerable<XElement> XE = items.Elements().Where(t => t.Name.ToString().Contains("id"));
                    foreach (XElement ppppp in XE)
                    {
                        //下面循环取出值。
                       string tid=ppppp.Element("tid").ToString();
                    }
    
                    var pp2 = items.Elements().Where(t => t.Name == "tidss").ToList().Count;
                    MessageBox.Show("tidss" + pp2.ToString());
    
                }
    

      

  • 相关阅读:
    Iscroll4使用心得 (转)
    请求接口数据实例
    jQuery插件开发全解析(转)
    js中可以改变作用域的三种方式(改变this)
    this基础(转)
    Hash扫盲
    JS编码解码 (转)
    自定义菜单实例
    DOM(转)
    js扫盲
  • 原文地址:https://www.cnblogs.com/xiaofengfeng/p/3092782.html
Copyright © 2011-2022 走看看