O'Reilly logo

Programming Visual Basic 2008 by Tim Patrick

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

XML Content

There's no better way to learn about XML than to start looking at it. If you've never used XML, but you've written some HTML, this should look somewhat familiar.

Some Basic XML

Here's a simple chunk of XML for you to enjoy:

<?xml version="1.0"?>
<hello>
   <there>
      <!-- Finally, real data here. -->
      <world target="everyone">think XML</world>
      <totalCount>694.34</totalCount>
      <goodbye />
   </there>
</hello>

Hey, I didn't say it was going to be interesting. As I mentioned before, it's just data, but it is useful data, and here's why:

It's obviously XML

This is clear from the first line, which always starts with <?xml . . . . This line also indicates the XML version number, which tells XML processing routines (parsers) to adjust behavior if needed. That's foresight.

It's structured

XML is a hierarchical data structure. That is, you can have data elements embedded inside other data elements to any depth you want. Every element is bounded by a set of tags. In this sample, the tags are hello, there, world, totalCount, and goodbye. Tags always appear inside <angle brackets>, and always appear in pairs, as in <hello>...</hello>. (This is where The Rule, "If you open it, close it," comes in.) Don't forget the / just before the tag name in the closing bracket. This syntax lets you organize your data into specifically arranged named units. For tag pairs that have nothing in between them, you can use the shortened syntax < tagname />, as I did with the goodbye tag. By the way, XML tags are case-sensitive, ...

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