C# linq(xml)中的多个位置?

C# linq(xml)中的多个位置?,c#,.net,xml,linq,C#,.net,Xml,Linq,我想通过在linq中提供linktextLast 3个月和SecondaryLink linkid s14来读取navlinksl63的链接id: <SecondaryLink> <LinkID> <![CDATA[s14]]> </LinkID> <LinkText> <![CDATA[All Brands]]> </LinkText> <LeftMenu>

我想通过在linq中提供linktextLast 3个月和SecondaryLink linkid s14来读取navlinksl63的链接id:

<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>

这就是linkid=s14

这里没有问题。注意到没有问号吗?您好,我想通过给linktextLast 3 Months和SecondaryLinkId s14一个问号来阅读navlinksl63的链接id,因为您的文章的第一位数字添加问号不会将其变成问题。因此,一般来说,不清楚SecondaryLink元素与LeftMenu有什么关系。@布鲁斯:XML格式在这里没有帮助。。。我看错了。将编辑,然后看看我是否可以检查你的答案。。。请注意,合理地格式化问题是任何提问者都可以做的事情,而不管他们的母语是什么。
    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");
    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");