【发布时间】:2011-05-13 21:56:36
【问题描述】:
我在一个文件中有以下 xml:
<Person>
<Name first="John" last="Doe" />
</Person>
我使用 XDocument.Load 加载了 xml 文档,但我似乎无法获取第一个和最后一个属性的值。
我试过了:
var q = from n in rq.Element("Name")
select n; //but q is null after this.
【问题讨论】:
-
它甚至可以编译吗? Element 方法返回一个不可枚举(或可查询)的 XElement,因此 LINQ 表达式应该无法编译。我猜你的意思是元素方法(复数)。
标签: c# linq-to-xml