SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 271 | Next

Scott Klein

"Professional LINQ"

Ancestors("Employee"))
listBox1.Items.Add(el.Value);
As you become more familiar with these methods, you will begin to understand the flexibility and usefulness
of what they can do for you.
Descendants
Descendants are those elements below the specified element in an XML tree. The Descendants method
returns a collection of elements that are descendants of the specified element, as the following example
shows. As stated earlier, this method returns an IEnumerable of XElement, and the results can be enumerated.
XElement root = new XElement("Employees",
new XElement("Employee",
new XElement("Name", "Scott"))
);
IEnumerable des =
from el in root.Descendants()
select el;
foreach (XElement el in des)
listBox1.Items.Add(el.Name);
This example simply asks for the descendants of the root node, returning the following:
Employee
Name
Another way to return the descendants, in less code, would be the following:
IEnumerable des = root.Descendants();
foreach (XElement el in des)
listBox1.Items.Add(el.Name);
This returns the exact same results as the preceding example.


Pages:
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6