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

Scott Klein

"Professional LINQ"

ElementsAfterSelf();
foreach (XElement el in els)
listBox1.Items.Add(el.Name);
The following is returned:
Element5
Element6
The following approach returns the same results:
IEnumerable re = root.Element("Element4").ElementsAfterSelf();
foreach (XElement el in re)
listBox1.Items.Add(el.Name);
Using the same XML tree, the following code queries the XML tree for those elements that are
before Element4:
XElement re = root.Element("Element4");
IEnumerable els = re.ElementsBeforeSelf();
166
Chapter 8: Advanced LINQ to XML Programming Topics
foreach (XElement el in els)
listBox1.Items.Add(el.Name);
Again, you could write it as follows:
IEnumerable re = root.Element("Element4").ElementsBeforeSelf();
foreach (XElement el in re)
listBox1.Items.Add(el.Name);
In both cases, the following values are returned:
Element1
Element2
Element3
Last, the overloads for these two methods return the elements after or before the current element that
also match the specified element name:
XElement re = root.Element("Element4");
IEnumerable els = re.


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