Home > Articles > Web Services > XML

Programming with LINQ to XML for Objects

  • Print
  • + Share This
LINQ to XML for Objects (a.k.a. LINQ to XSD) is an extension to LINQ that uses an XML schema to code-generate strongly typed objects, permitting you to objectify XML data. Paul Kimmel shows how it works.
Like this article? We recommend

Like this article? We recommend


People are what matter; everything else is window dressing.

—Jackson Wayfare

Language Integrated Query (LINQ) is an integrated query language. LINQ basically permits you to write SQL-like queries against objects, data, and more. Instead of learning XPath or XQuery for XML, SQL for SQL Server databases, LDAP for Active Directory, and writing raw C# or Visual Basic .NET code for objects, you can learn LINQ and use LINQ to query your data—no matter where the data originates.

LINQ provides the interface IQueryProvider. By implementing IQueryProvider, you can write code that converts LINQ queries to the query language your source needs, such as LINQ to SQL. Because of its built-in extensibility, LINQ will continue to be extended into new places, such as Active Directory LDAP. In fact, this built-in extensibility is behind the subject of this article, LINQ to XML for Objects (generally referred to as LINQ to XSD).

LINQ to XSD uses the CodeDOM and LINQ technologies to generate strongly typed wrapper classes based on an XML schema (.XSD) file. The result is that you can treat XML data like in-memory objects, querying them easily with LINQ. The LINQ to XSD bits are still in prerelease mode, so you'll need to download them for the demo discussed here.

  • + Share This
  • 🔖 Save To Your Account