O'Reilly logo

Microsoft® Visual Basic® 2010 Developer’s Handbook by Klaus Löffelmann and Sarika Calla Purohit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Processing XML Documents—Yesterday and Today

To create or change an XML structure in Microsoft Visual Basic 2005 and earlier versions required significant developer efforts. For example, here’s what you had to do to extend the following XML structure that saves vehicle data by adding a modelYear element:

 <fleet>
  <licensePlate>MS - VB 2010</licensePlate>
  <load amount="10 Tons">Salt</load>
  <manufacturer>Mack</manufacturer>
  <modelYear>1998</modelYear>
</fleet>

In Visual Basic 2005, the code is:

Dim xml As New XmlDocument xml.Load(Application.StartupPath + "\fleet1.xml") Dim nodeList As XmlNodeList = xml.GetElementsByTagName("fleet") 'In case there are more: loop For Each node As XmlNode In nodeList Dim xmlElement As XmlElement = xml.CreateElement("modelYear") ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required