Skip to Content
ASP.NET 3.5 For Dummies®
book

ASP.NET 3.5 For Dummies®

by Ken Cox
February 2008
Intermediate to advanced
428 pages
8h 52m
English
For Dummies
Content preview from ASP.NET 3.5 For Dummies®

7.7. Using LINQ to Create and Query XML

LINQ to XML uses LINQ syntax to generate, read, and sort XML data. LINQ to XML uses its own set of objects, such as XDocument, XElement, and XAttribute to represent parts of an XML document. It isn't quite as straightforward as regular LINQ, but as you can see in the next few paragraphs, the basic techniques are the same.

In this section, you build a class that holds information about family members (nieces and nephews). Next, you create objects from the class and configure the object properties.

The objects become the data source for an XML document that you save to a file on the Web server. In the final phase, you read the XML file and filter its data via LINQ syntax.

7.7.1. Creating the KinFolk class

The KinFolk class represents a niece or a nephew. To keep the code short, you record only the person's first name, gender, and father's name.

The KinFolk class uses the private variables _fname, _gender, and _father as well as the corresponding public properties Fname, Gender, and Father. To create the KinFolk class, follow these steps:

  1. Add a class file named kinfolk.vb to the App_Code folder of your project (FileNew FileClassAdd).

  2. Use contents ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 Unleashed

ASP.NET 3.5 Unleashed

Stephen Walther
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470195925Purchase book