Udostępnij za pośrednictwem


Processing XML Data with LINQ to XML (Silverlight)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

LINQ to XML is a LINQ-enabled, in-memory XML programming interface that enables you to work with XML from within the .NET Framework programming languages.

LINQ to XML is like the Document Object Model (DOM) in that it brings the XML document into memory. You can query and modify the document, and after you modify it you can save it to a file or serialize it and send it over the Internet. However, LINQ to XML differs from the DOM: It provides a new object model that is lighter weight and easier to work with, and that takes advantage of language improvements in Visual C# 2008.

The most important advantage of LINQ to XML is its integration with Language-Integrated Query (LINQ). This integration enables you to write queries on the in-memory XML document to retrieve collections of elements and attributes. The query capabilities of LINQ to XML is comparable in functionality (although not in syntax) to XPath and XQuery.

For conceptual and how-to information about programming with LINQ to XML in the .NET Framework, see LINQ to XML. Note that the .NET Framework for Silverlight includes a subset of the .NET Framework class library, and some of the examples in the LINQ to XML documentation will not work in Silverlight. For example, code that uses the Extension bridge classes defined in the System.Xml.Schema namespace or XSLT will not work, because these features are currently not supported in the .NET Framework for Silverlight.

For more information about the differences between the two frameworks, see Processing XML in the .NET Framework vs. the .NET Framework for Silverlight.

NoteNote:

In your Silverlight project, you must reference the .NET Framework assemblies that are installed with Silverlight, instead of those that are installed with Visual Studio.

In This Section

See Also

Concepts

Other Resources