Welcome to MSDN Blogs Sign in | Join | Help

Wriju's BLOG

.NET and everything
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.

 

Namoskar!!!

Posted: Thursday, February 07, 2008 12:59 AM by wriju

Comments

Noticias externas said:

This is the one feature which can make VB.NET developers feel better than C# folks. I have seen people

# February 6, 2008 9:18 PM

Wriju's BLOG said:

I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate

# February 7, 2008 6:17 PM

Wriju's BLOG said:

I have discussed about the native XML support in VB.NET code editor in one of my BLOG posts. Now to generate

# February 7, 2008 8:06 PM

BusinessRx Reading List said:

While XML literal features in Visual Basic get all the love , the new XElement API for the CLR makes

# May 4, 2008 9:15 PM

Community Blogs said:

While XML literal features in Visual Basic get all the love , the new XElement API for the CLR makes

# May 20, 2008 2:52 PM

Sanay said:

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........

# June 7, 2009 2:56 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker