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 272 | Next

Scott Klein

"Professional LINQ"


This method also takes an overload, which returns all of the descendants that have the specified name,
as this code illustrates:
IEnumerable des =
from el in root.Descendants("Employeee")
select el;
foreach (XElement el in des)
listBox1.Items.Add(el.Name);
163
Part II: LINQ to XML
This example asks for the descendants of the Employee node, returning the following:
Name
Again, you could write the example as follows:
IEnumerable des = root.Descendants("Employeee");
foreach (XElement el in des)
listBox1.Items.Add(el.Name);
Just to make things a bit more complicated, let??™s add another employee and return the values of the
descendants of the employee node, which in essence is asking for the value of the Name node because it is
a descendant of the Employee node:
XElement root = new XElement("Employees",
new XElement("Employee",
new XElement("Name", "Scott"))
,
new XElement("Employee",
new XElement("Name", "Bob"))
);
textBox1.Text = root.ToString();
IEnumerable des = root.Descendants("Employee");
foreach (XElement el in des)
listBox1.


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