1. Home
  2. Computing & Technology
  3. Visual Basic

Visual Basic .NET 2008 Express - Using XML

A SigBlock XML File

By Dan Mabbutt, About.com

Jun 12 2008

The starting value of the data items we need in our signature block program are:

DanTrueMabbuttTrueAbout Visual BasicTrue(555) 555-5555False123-45-6789Falsevisualbasic@about.comTrue

These values are listed as one long string to illustrate a programming problem that's solved with XML. (If they're broken into more than one line, it's because the text space isn't wide enough to display them as a single string.) If you compare this string with the structure in the downloadable source code (available in the part 7 download), you will be able to see that ...

Dan is the value for the FName variable
True is the value for the FNameChecked variable
Mabbutt is the value for the LName variable

... and so forth.

But with just the raw data shown above, writing a program to assign these values to the variables could be difficult. The program has to know exactly what order the fields are in, where one field stops and another starts, and it might be handy to have some information about the fields too. (Is a phone number a home phone or a business phone, for example.)

One thing XML does is provide a way to identify data in a file so a program, or even a person just looking at the file using Notepad, can easily see exactly what the data is. I created this XML version of the data using Notepad:

<?xml version="1.0" encoding="utf-8"?>
<SigBlocks>
   <SigBlock>
      <FName>Dan</FName>
      <FNameChecked>True</FNameChecked>
      <LName>Mabbutt</LName>
      <LNameChecked>True</LNameChecked>
      <Address>About Visual Basic</Address>
      <AddressChecked>True</AddressChecked>
      <Phone>(555) 555-5555</Phone>
      <PhoneChecked>False</PhoneChecked>
      <SSN>123-45-6789</SSN>
      <SSNChecked>False</SSNChecked>
      <Email>visualbasic@about.com</Email>
      <EmailChecked>True</EmailChecked>
   </SigBlock>
</SigBlocks>

You can see what the data is much more easily now. But the really useful thing is that computers can identify it more easily too! On the next page, we show how to create a type of XML file from the Signature Block information called SOAP.

Explore Visual Basic

More from About.com

  1. Home
  2. Computing & Technology
  3. Visual Basic
  4. Learn VB.NET
  5. Visual Basic .NET 2008 Express - Using XML

©2008 About.com, a part of The New York Times Company.

All rights reserved.