XML から特定のノードを取得するための LINQ クエリを作成するのに問題があります。誰かが助けてくれることを願っています。XML は次のとおりです。
<EmpFieldsMap>
<Field>
<Name insert = "false">EmpNumber</Name>
</Field>
<Field>
<Name insert = "true">EmpName</Name>
</Field>
<Field>
<Name insert = "true">EmpLocation</Name>
</Field>
<Field>
<Name update = "false">EmpAddress1</Name>
</Field>
<Field>
<Name update = "false">EmpAddress2</Name>
</Field>
<Field>
</EmpFieldsMap>
ご覧のとおり、一部のNameタグには属性insertがあり、他のタグにはupdate属性があります。
insert属性を持たず、insertasを持つタグを取得する必要がありますtrue。、、、およびInsertCollectionが必要であることを意味します。EmpNameEmpLocationEmpAddress1EmpAddress2
このコード:
var titles = from nameTag in xml.Element("EmpFieldsMap").Elements("Field")
let insert = nameTag.Attribute("insert") ?? new XAttribute("insert","true")
where insert.Value == "true"
select nameTag.Element("Name").Value;
句Fieldを無視して、5 つのタグ値すべてを指定します。Where
私は何が欠けていますか?