Visual Basic XML Transform - TechEd demo prep

Visual Basic XML Transform - TechEd demo prep

  • Comments 7

Hello from Orlando! I’ve been at TechEd 2007 this week in very sunny Orlando. As part of my demo prep, I had to create a little xml transform to convert the TechEd schedule that I got off the website in an Excel XML format into a more readable xml file format. I could have done this all with one transform, but the newer XML file format made for good demo fodder to show off the XML Intellisense features coming in Orcas Beta2.

I thought the code was interesting and fun – a great blend of XML properties, XML Literals, and query – so I’ve posted it below:

Imports System.IO

Imports <xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">


Module Module1


 'Metadata info

 Enum Column










 End Enum


 Sub Main()


  Dim fromFile = "C:\TechEdScheduleExcelFormat.xml"

  Dim toFile = "C:\MyXMLFormat.xml"

  Dim excelXML = XElement.Load(fromFile)


  ' Remove first row - metadata info



  Dim xml = _

   <?xml version="1.0"?>

   <EventSchedule Event="TechEd2007">

    <%= _

     From session In excelXML...<ss:Row> _

     Let info = session...<ss:Data> _

     Select _

      <Event ID=<%= info(Column.Code).Value %>>

       <Title><%= info(Column.Title).Value %></Title>

       <Description><%= info(Column.Description).Value %></Description>

       <Track><%= info(Column.Track).Value %></Track>

       <Session><%= info(Column.Session).Value %></Session>

       <Level><%= info(Column.Level).Value %></Level>

       <Speaker><%= info(Column.Speaker).Value %></Speaker>

       <Room><%= info(Column.Room).Value %></Room>

       <TimeSlot><%= info(Column.Timeslot).Value %></TimeSlot>

      </Event> _





   Shell("C:\Program Files\Internet Explorer\iexplore.exe " & toFile, AppWinStyle.MaximizedFocus)


 End Sub

End Module


All this, so that in the demo, I could:

1)      Open the resulting file, “MyXMLFormat.xml”, in Visual Studio

2)      Right click on the XML menu item

3)      Select create schema to infer an XSD from that file:

Create Schema


4)      Save the schema as an XSD and add it as an existing item in my project:

Save as XSD 

5)      And get an awesome Intellisense experience over the XML:

XML Intellisense


Pretty cool, no?

Leave a Comment
  • Please add 5 and 5 and type the answer here:
  • Post
  • If you have multiple schemas how does it know which one to use ?

  • Charlie's got a great post of his first day's experience in the TechEd expo. Looks like Amanda is still

  • Amanda,

    Process.Start("FileName.xml") from System.Diagnostics is a more .NET Fx-flavored alternative to Shell.


  • Hi Bill - Good question. If you have two XSDs in the project, they will both show up at the top level. But because the Intellisense will be filtered based on what you type, the XSDs will quickly disambiguate themselves in the completion lists.

    Roger -

    The Shell function ships with the .NET frameworks in the Microsoft.VisualBasic.dll - so, it's a fine, Fx flavored, alternative to Process.Start.


  • Hooray! Visual Basic 2008 Beta2 has been released to the wild today to return to its natural habitat

  • Hooray! Today we’ve finally shipped Visual Studio 2008, previously known as “Orcas”, previously known

  • Yesterday I promised to post about the hidden gems in Visual Basic and Visual Studio 2008 that you haven&#8217;t

Page 1 of 1 (7 items)