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

Scott Klein

"Professional LINQ"

Element("Name")
Granted, there is much more you can do, but this is just to whet your appetite. Keep in mind you can do
the same with attributes. All of this is explained in more detail in Chapter 6.
The following is a simple example of returning elements of a particular node. It creates an XML document
containing several riders, with each rider containing one attribute.
XElement xdoc = new XElement("Riders",
new XElement("Rider",
new XElement("Name", "Ricky Carmichael",
new XAttribute("Class", "450")),
new XElement("NationalNumber", "4"),
new XElement("Brand", "Suzuki"),
new XElement("Nickname", "GOAT"),
new XElement("Mechanic", "Mike Gosselaar")
),
new XElement("Rider",
new XElement("Name", "Damon Bradshaw",
new XAttribute("Class", "450")),
new XElement("NationalNumber", "45"),
new XElement("Brand", "Yamaha"),
new XElement("Nickname", "Beast from the East"),
new XElement("Mechanic", "N/A")
),
111
Part II: LINQ to XML
new XElement("Rider",
new XElement("Name", "Chad Reed",
new XAttribute("Class", "450")),
new XElement("NationalNumber", "22"),
new XElement("Brand", "Yamaha"),
new XElement("Nickname", "N/A"),
new XElement("Mechanic", "N/A")
),
new XElement("Rider",
new XElement("Name", "James Stewart",
new XAttribute("Class", "450")),
new XElement("NationalNumber", "7"),
new XElement("Brand", "Kawasaki"),
new XElement("Nickname", "N/A"),
new XElement("Mechanic", "N/A")
),
new XElement("Rider",
new XElement("Name", "Kevin Windham",
new XAttribute("Class", "450")),
new XElement("NationalNumber", "14"),
new XElement("Brand", "Honda"),
new XElement("Nickname", "N/A"),
new XElement("Mechanic", "N/A")
)
);
textBox1.


Pages:
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6