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

Scott Klein

"Professional LINQ"


106
Chapter 5: Understanding LINQ to XML
Once the XML document is created, the NodesAfterSelf method of the XElement class is used to return
all the elements after the element. Those elements are then iterated through and added to
the list box. This example requires a Using statement to System.Xml.
XElement doc = new XElement("Root",
new XElement("Employees",
new XElement("Employee",
new XAttribute("id" "1"),
new XElement("Name", "Scott Klein"),
new XElement("Title", "Geek"),
new XElement("HireDate", "02/05/2007"),
new XElement("Gender", "M")
)
)
);
XElement xele = xtree. Element("Employees").Element("Employee"). Element("Name");
IEnumerable nodes =
from node in xele.NodesAfterSelf()
select node;
foreach (XNode inode in nodes)
listBox1.Items.Add(inode.NodeType == XmlNodeType.Element ?
(inode as XElement).Value : "");
Now you should be able to see how easy and efficient it is to work with XML in LINQ to XML, using the
available classes to create, query, and manipulate XML.
LINQ to XML Programming Concepts
This section explores LINQ to XML programming concepts such as how to load XML, create XML from
scratch, manipulate XML information, and traverse an XML document.


Pages:
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6