开发者

Multiple where in linq (xml)?

I want to read link id of navlinks(l63) by giving linktext(Last 3 Months) and SecondaryLink linkid s14 in linq:

<SecondaryLink>
  <LinkID>
    <![CDATA[s14]]>
  </LinkID>
  <LinkText>
    <![CDATA[All Brands]]>开发者_开发技巧;
  </LinkText>
  <LeftMenu>
    <NavLinks>
      <LinkID>
        <![CDATA[l63]]>
      </LinkID>
      <LinkText>
        <![CDATA[Last 3 Months]]>
      </LinkText>
    </NavLinks>
  </LeftMenu>
</SecondaryLink>

This is what I have, I want to give one more where condtion in this.

 string secondaryid = doc.Descendants()
                         .Elements("LinkText")
                         .Where(x => x.Value == "Last 3 Months")
                         .Single()
                         .Parent
                         .Element("LinkID").Value;

that is linkid=s14


    var q = from c in xml.Descendants("SecondaryLink")
            where (string)c.Element("LinkID") == "s14"
            where (string)c.Element("LeftMenu").Element("NavLinks").Element("LinkText") == "Last 3 Months"
            select c.Element("LeftMenu").Element("NavLinks").Element("LinkID");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜