Partilhar via


VB.NET 9.0: XML Literal

This is the one feature which can make VB.NET developers feel better than C# folks. I have seen people complaining about MS saying that MS has done lot for C# but not equally for VB.NET. One of the biggest was Refractoring. There are so many such. But this feature is just “SPELLBOUND” when I first experienced it.

 

Today, people handle XML from .NET in many ways. One approach is they simply concatenate the string to create XML string and end up writing to a file. Another is they generate DataSet/DataTable and uses WriteXml() method to write Xml to a file. More sophisticated way is to use System.Xml namespace and build Xml step by step in strongly typed manner. But this one is something which is simply amazing.

 

In Visual Studio 2008 if you write something using System.Xml.Linq

Dim _xml2 = New XElement("ProcessList", _

                New XElement("Process", _

                    New XAttribute("ThreadCount", "2"), "Some Process"))

 

You can also write,

Dim _xml = <Processes>

               <Process ThreadCount="2">Some Name</Process>

           </Processes>

 

 

These two statements are identical. Second one looks like an ASP.NET page but it is actually XElement object. But the feeling you will get as if you are writing an Xml in a XML Editor.

 

Coolest ever.

Today I found an article with very detailed discussion https://geekswithblogs.net/Silverlight2/archive/2008/03/30/xml-literals-and-embedded-expressions.aspx

 

Namoskar!!!

Comments

  • Anonymous
    February 06, 2008
    This is the one feature which can make VB.NET developers feel better than C# folks. I have seen people

  • Anonymous
    February 07, 2008
    I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate

  • Anonymous
    February 07, 2008
    I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate

  • Anonymous
    May 04, 2008
    While XML literal features in Visual Basic get all the love , the new XElement API for the CLR makes

  • Anonymous
    May 20, 2008
    While XML literal features in Visual Basic get all the love , the new XElement API for the CLR makes

  • Anonymous
    June 07, 2009
    Hi i am new in vb.net I want to convert xlsx file to xls  file using vb.net Can any one help me please........

  • Anonymous
    August 25, 2009
    i'm stuck making a alphanumeric pager I need to filter out my "glossary.xml" file by first letter of the "word" node can you help me do that? or how do I filter xml files via vb? thanks in advanced, jav

  • Anonymous
    June 27, 2010
    I do not understand about programming languages. but which I understand is getting a lot of friends going to get better: D

  • Anonymous
    July 11, 2011
    asalu intaki literls in side headings evi?????