gpt4 book ai didi

c# - Linq to XML 问题 : Why is my query not working

转载 作者:太空宇宙 更新时间:2023-11-03 18:40:53 25 4
gpt4 key购买 nike

在我的问题点,我在 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>

这是 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");

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

我在这里错过了什么?

最佳答案

由于 XML 区分大小写,请尝试用“identifier”替换上一条语句中的“Identifier”。

关于c# - Linq to XML 问题 : Why is my query not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9041457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com