Paste XML as LINQ Sample

This project is a Visual Studio add-in that enhances the feature set found in the integrated development environment (IDE) by enabling users to automatically convert valid XML to the corresponding LINQ to XML statements. The Express versions of Visual Studio do not support add-ins.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  1. After building, copy the XmlToXLinq.dll and XmlToXLinq.Addin files to a directory that you may have to create named:

    ..Documents\Visual Studio 2008\Addins

  2. You may have to restart Visual Studio after you copy the files.

  3. To see the add-in in action, select some XML and paste it into a C# source file. From the Edit menu, click Paste XML as XElement. Note that the item will not appear in the menu unless something is on the Clipboard.

  4. Here is a sample snippet of XML that you can use:

    <mynode></mynode>
    The result of pasting this in should look like this:
    XElement xml = new XElement("mynode", "");
    

Note

Many LINQ samples require XML files and/or the version of the Northwind sample database that is located in the Data sample. If you install the Data Sample in the same parent folder as the other LINQ samples, the path for the XML files and database file will be resolved automatically. Many sample files also require the Object Dumper Sample project.

See Also

Tasks

Sample Queries