Extensible Markup Language (XML) files are often used for exchanging information between programs, both on and off the Web. XML files are similar to HTML files in two ways: both are plain text files that indicate formatting within tags, and both use start and end tags. However, HTML tags describe how elements should look, whereas XML tags specify the structure of the elements in a document. Also, as its name implies, the XML tag set is extensiblethere are ways to add your own tags. Here is an example of a simple XML file: <?xml version="1.0"?> <ORDER> <CUSTOMER>Mindy Martin</CUSTOMER> <PRODUCT> <ITEM>Sterilized Soil</ITEM> <PRICE>$8.65</PRICE> <QUANTITY>1 bag</QUANTITY> </PRODUCT> </ORDER> This simple file describes an order that Mindy Martin (the customer) placed for one bag (the quantity) of Sterilized Soil (the item) at a cost of $8.65 (the price). As you can see, when the data's structure is tagged rather than its appearance, you can easily import the data into a database table. An actual file created for this purpose would contain many instances of the <order> through </order> block, one for each order. The information in an Access table consists of data and structure. When a table is exported to XML, the data and structure can be exported to separate files, in which case the data is placed in an .xml file, and the structure is placed in an .xsd file, which is referred to as a schema. (The structure can also be embedded in the .xml file.) In the following exercise, the Orders file contains both data and structure, and the Order Details files store the data in one file and the structure in another. If the structure is stored in an .xsd file, make sure it is in the same folder as the matching .xml file, otherwise Access will import the data and assign default properties to all fields. In this exercise, you will import XML documents into an Access database.
USE the 06_ImportXML database, the 06_Orders XML file, and the 06_OrderDetails XML and schema files. These practice files are located in the Chapter03 subfolder under SBS_Access2007. OPEN the 06_ImportXML database.
CLOSE the 06_ImportXML database. |