的XElement儿童 [英] Children of XElement
问题描述
我如何得到的XElement的只是孩子?
How do I get just the children of an XElement?
我目前使用的XElement.Descendants()函数,该函数返回XElements的各个层面,而不是刚子节点。
I am currently using the XElement.Descendants() function, which returns all levels of XElements, rather than just the child nodes.
我真的想只是孩子们的IEnumerable
What I would really like is an IEnumerable of just the children.
推荐答案
一个直接子元素的XElement 通过调用 元素访问()
或 元素()
功能。 。使用重载用名称来访问特定的元素,或没有访问所有子元素
The immediate child elements of one XElement are accessible by calling the Element()
or Elements()
functions. Use the overloads with a name to access specific elements, or without to access all child elements.
有也很喜欢的 属性()
和的 属性()
了你可能会发现有用的。
There are also similar methods like Attribute()
and Attributes()
that you might find useful.
这篇关于的XElement儿童的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!