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

Scott Klein

"Professional LINQ"

Items.Add(el.Value);
When run, this code produces the following output:
Scott
Bob
Hopefully, you are starting to see how easy it is to work with these axis methods.
AncestorsAndSelf
The AncestorsAndSelf method is almost identical to the Ancestors method, but it varies in the fact that
it returns the current element along with its ancestors. The following example constructs a simple XML
tree, and then queries the XML for the Employee node and its ancestor nodes:
XElement root = new XElement("Employees",
new XElement("Employee",
new XElement("Name", "Scott"))
);
textBox1.Text = root.ToString();
XElement ce = root.Element(("Employee");
IEnumerable des =
164
Chapter 8: Advanced LINQ to XML Programming Topics
from el in ce.AncestorsAndSelf()
select el;
foreach (XElement el in des)
listBox1.Items.Add(el.Name);
An XElement variable is declared to specify the element at which to start the ancestor search. That variable
is then used to apply the AncestorsAndSelf() method.
Equally, you could also do the following:
IEnumerable des =
root.


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