Program a Visual Basic XML Database
XML is the newest "golly gee wiz" buz word on the net today (well actually "WiFi"
is, but that's another story). Basically XML is tags, similar to html tags, that
you place around data. Html tags define how to display a Web page. XML tags describe
the data contained in the Web page or document. Because XML is a W3C standard, it has
found a use in communicating between dissimilar databases.
For efficiency, most databases are stored in binary format and are not human
readable without the dbm (database management system). Several times I have lost
databases because they became corrupted. I wished I could open the database in a
text editor to see what was wrong and possibly make a repair. I like XML because it's
human readable ASCII text, not binary data.
There are many books available that teach you how to properly construct an XML
document, but there is very little information available about how to do something
with XML. In this article I show you how to program an XML database with Visual Basic.
I assume that you already know how to program a simple Visual Basic .EXE project.
Other than that this article is for beginners.
convenience I have zipped together the Visual Basic source files and the XML document
used for this example, which you can download by clicking here
The database that I describe in this article will be a simple flat database.
Whereas a relational database contains several tables, along with relations
between the tables, a flat database contains only one table. The disadvantage of a flat
database is that sometimes data is repeated in the table.
This example consists of two parts, an XML document and a Visual Basic program that
is used to browse, search, and edit the XML document. In this article I will be referring
to the XML document as the "database". The nice thing about XML is that it is a standard,
so you are not confined to reading the database with any specific application. You can
read this database with any XML document reader including Internet Explorer or any
ASCII text pad program.
The example database contains all the different modes which can be set for a
computers display. Each record will contain the fields; resolution, number of color
bits, number of colors, and bytes of memory for a full screen. Shown below is one
record from the database.
640x480 4 16 153,600