VB XML schema goodness

Posted Sun, Aug 12 2007 2:40 by bill

VB9 provides intellisense support for XElement if you add the schema to the project and import the relevant namespaces.  This is just awesome !  Earlier tonight I wanted a list of shortcuts for all the snippets so I added the snippet schema to the project and the namespace imports as default:

 

Imports <xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

 

Then I got all the files use My.Computer.FileSystem.GetFiles with a wildcard or "*.snippet" and wrote a query over the files :

Dim shortcuts = From f In files _
                Let xEl = XElement.Load(f) _
                Let value = xEl.<CodeSnippet>.<Header>.<Shortcut>.Value _
                Select value

 

That's it !

 

But the nice thing was intellisense listed <CodeSnippet> <Header> and <Shortcut> for me.

image

 

And notice how it filters as you move inside elements:

image

 

How sweet it is to use VB for XML in VB9 !!!

Filed under: , , ,