Linq to XML问题:为什么我的查询不起作用

dha*_*ton 1 c# xml linq-to-xml

在我的问题上,我在XElement中有以下XML.完整的XML中可以有许多这些"标识符"节点,我的导航工作到此为止.

    <Identifiers>
      <identifier>
        <Type>MR</Type>
        <Value>123321</Value>
        <Authority></Authority>
      </identifier>
      <identifier>
        <Type>AN</Type>
        <Value>123321-01</Value>
        <Authority></Authority>
      </identifier>
      <identifier>
        <Type>PN</Type>
        <Value>123321</Value>
        <Authority></Authority>
      </identifier>
    </Identifiers>
Run Code Online (Sandbox Code Playgroud)

这是Linq-To-XML:

    id = xd.Root.Element("Patient");
    id = id.Element("Identifiers"); //At this point "id" contains the above XML.
    id = id.Elements("Identifier").FirstOrDefault(x => x.Element("Type").Value == "AN");
Run Code Online (Sandbox Code Playgroud)

是它崩溃的最后一个语句,并返回null.

我在这里错过了什么?

mel*_*eek 6

由于XML区分大小写,因此尝试使用"标识符"替换上一个语句中的"标识符".