Ask a questionAsk a question
 

AnswerXml Literals in C#

  • Thursday, May 11, 2006 9:29 PMJerod Moemeka Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi,

      I dont know if someone already answered this question but, how come c#'s version of xlinq (, or c#3.0, or c# orcas, or whatever it's called now) does not include xml literals!  I cant imagine a reason not to include thins functionality beyond being too hard to do in c# or something like than.

Answers

  • Friday, May 12, 2006 2:59 AMMatt Warren - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The C# design team has prioritized language changes like XML literals down quite a bit, believing that the XLinq constructors offer an equivalent degree of functionality. However, we are generally open on these sorts of things. If we get a lot of feedback from the community like yours we may reconsider our position.
  • Sunday, May 14, 2006 5:17 AMAnders Hejlsberg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    The LINQ CTP includes a Visual Studio Add-in for this. It's pretty easy to use. Just copy some XML onto the clipboard. Then use "Paste XML as XElement" on the Edit menu and you'll get the XLinq code required to create that XML.

    Anders

All Replies

  • Friday, May 12, 2006 2:59 AMMatt Warren - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The C# design team has prioritized language changes like XML literals down quite a bit, believing that the XLinq constructors offer an equivalent degree of functionality. However, we are generally open on these sorts of things. If we get a lot of feedback from the community like yours we may reconsider our position.
  • Friday, May 12, 2006 4:55 AMDinesh Kulkarni - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    There is also an XML-paster feature in the latest preview that you may want to try out.

    Thanks.

    Dinesh

  • Friday, May 12, 2006 7:21 PMJerod Moemeka Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Can you point me in the right direction to see this
  • Sunday, May 14, 2006 5:17 AMAnders Hejlsberg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    The LINQ CTP includes a Visual Studio Add-in for this. It's pretty easy to use. Just copy some XML onto the clipboard. Then use "Paste XML as XElement" on the Edit menu and you'll get the XLinq code required to create that XML.

    Anders

  • Wednesday, March 12, 2008 7:13 PMLennie De Villiers DG Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Where I can find this in VS.Net 2008?

    Kind Regards,

    Lennie De Villiers

  • Wednesday, March 12, 2008 8:12 PMIon Vasilian Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    In VS 2008, from the main menu: Help/Samples/LocalSamplesFolder/CSharpSamples/LinqSamples/PasteXmlAsLinq.

     

    Ion

     

  • Wednesday, October 07, 2009 10:40 PMSydney Osborne Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    That's very nice (honestly), but it doesn't handle something like this (from Beth Massey's dynamic Xaml example - http://code.msdn.microsoft.com/dynamicWPF/Release/ProjectReleases.aspx?ReleaseId=1201).  So, my vote is for adding XML Literals to C#.

    <

     

     

    Grid xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="Grid1">
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="100*"/>
    <ColumnDefinition Width="200*"/>
    </Grid.ColumnDefinitions>
    <StackPanel Name="StackLabels" Margin="3">
    <%= From column In Me.TableSchema _ 
    Where column.IsPrimaryKey = 0 AndAlso column.DataType <> "timestamp" _ 
    Select <Label Height="28" Name=<%= column.ColumnName & "Label" %>
    HorizontalContentAlignment="Right">
    <%= column.ColumnName %>:</Label> %>
    </StackPanel>
    <StackPanel Grid.Column="1" Name="StackFields" Margin="3">
    <%= From column In Me.TableSchema _ 
    Where column.IsPrimaryKey = 0 AndAlso column.DataType <> "timestamp" _ 
    Select GetUIElement(column) %>
    </StackPanel>
    </Grid>