C# Linq到XML选择与模式匹配的子元素名称列表
关于嵌套LINQ到XML查询的问题: 代码: 但这就产生了一个错误: 源类型为“System.Collections.Generic.IEnumerable”的查询表达式中的后续from子句中不允许使用类型为“System.Xml.Linq.XAttribute”的表达式。调用“SelectMany”时类型推断失败C# Linq到XML选择与模式匹配的子元素名称列表,c#,linq-to-xml,C#,Linq To Xml,关于嵌套LINQ到XML查询的问题: 代码: 但这就产生了一个错误: 源类型为“System.Collections.Generic.IEnumerable”的查询表达式中的后续from子句中不允许使用类型为“System.Xml.Linq.XAttribute”的表达式。调用“SelectMany”时类型推断失败 只能对返回集合的表达式使用from。 .Attribute(“Name”)不返回集合,因此该行没有意义 你可能想要 let subSubResponse = subResponse.
只能对返回集合的表达式使用
from
。.Attribute(“Name”)
不返回集合,因此该行没有意义
你可能想要
let subSubResponse = subResponse.Attribute("Name")
或者只是
select subResponse.Attribute("Name").Value
我使用了您的“selectsubresponse.Attribute(“Name”).Value”,非常有效。谢谢
from subSubResponse in subResponse.Attribute("Name")
select subResponse.Value
let subSubResponse = subResponse.Attribute("Name")
select subResponse.Attribute("Name").Value