![]() |
VB Database: Challenge Lab Week 3Since you have an idea of what the data structures are for our china shop, it's time to take a side-trip over to XML-land. The easiest way to deal with XML is to remember that it's mainly about data: XML's function is to describe (store, carry and exchange) data, and to focus on what data is. XML itself does not do anything; it's a way to do something. And XML cares only about data, not about presentation. In order to send, receive or display the data that XML is storing/carrying/exchanging, a program would have to written. We'll use Internet Explorer 5.0 (and up) to display this week's output. Here's what a sample XML document looks like. This came from a database with a table called Employees. The table has two fields, Name and Salary:
It's a normal text document that has been saved as employees.xml. You open it up in IE5.x/6 and it will look like this:
Not terribly different than the code inside the text file. About all IE contributes is the handy little expand/contract plus/minus signs, and some color coding and bolding. (We'd have to apply a style sheet in order to make it look pretty, but don't worry about that right now.) The first line, The next line, XML data is hierarchical. Nested in the root element are child elements, Elements can contain nested elements, text or both. The "employee" element contains only nested elements. The "name" and "salary" elements contain text. It's possible that an element may contain neither child elements or text - these are called Empty elements and have a special syntax that combines the start and end tags. Let's say we had an element called permanent_staff. For now it has no data associated with it. We would write it out like this:
(Those of you with some exposure to XHTML will see a similarity between how you are to handle tags
like There are also attributes, but we'll save those for another time. Much ink and many pixels have been expended on whether to use attributes or elements. (I fall more into the element camp, personally.) XML is a very picky languge. Much, much more picky than HTML. It is absolutely unforgiving if you violate any rules. An XML document is said to be a well-formed XML document if it follows these rules:
Incidentally, there is a difference between "well-formed" and another term called "valid", but that, too, will be saved for another time. Only a well-formed document can be displayed in IE5.x/6. If we change the capitalization of the start tag of the first "name" element to proper case, but don't change the end tag, IE tells us this:
The element names themselves are subject to rules, as well:
So... All that being said, your assignment is to take the China Shop database you created (or downloaded) and turn those tables into XML documents. (Please ask questions if I wasn't clear enough :-) Note: Access 2002 has the ability to save a table as XML. Don't do that for this exercise. Create the XML file from scratch. (Just remember copy and paste is your friend :-) Alrak's Course Resources ©2002-2007 Karla Carter. All rights reserved. This material (including, but not limited to, Mini-lectures and Challenge Labs) may not be reproduced, displayed, modified or distributed without the express prior written permission of the copyright holder. For permission, contact Karla. |