Share this Page URL

Chapter 16. Working with XML Data in Acc... > Exporting an Access Table to an XML ... - Pg. 569

Working with XML Data in Access <CampaignExpenses> </CampaignExpenses> 569 Between each of these tags is another set of tags that contain the names of the table fields, and these contain the data from the Access database. Each of these sets of tags along with their data represents one record in the Access table. If you do a side-by-side comparison, you should see a one-to-one correspondence of records. Using CDATA Constructs to Display Strings in XML You might notice an odd-looking field value in your XML output that begins with "![ CDATA ["CDATA essentially is a tag for text data that allows you to include illegal characters in your text string. For example, because most XML parsers will interpret a left angle bracket (<) as the start of a tag element, it wouldn't be possible to include a literal string that contains a left angle bracket without causing a parser to interpret it as markup. (This is what makes the string character "illegal.") The parser would then see the markup as incomplete (because it doesn't have a corresponding right angle bracket), and you might get a parser error. However, if you enclose your literal text string with CDATA markup, the parser will not attempt to interpret the string in the CDATA section but will treat it as a text string. When might you use an XML document that was exported from Access to store data instead of just using Access? Here are some scenarios where using an XML document in conjunction with Access might be preferred to using Access alone: · You have a one-time need for a simple, Web-based tool that will allow people in your organization to register for a company party. You don't really need the more powerful tools in Access, so an Access database is overkill. You just want to be able to capture the data from a Web page and print the results. In this case, you might use Access to create the data structure and field con- straints, export the table to an XML document, and then use that XML document as the basis for your Web-based tool. · You need to capture student information for a small class you're teaching. The data remains fairly static but is updated once or twice in the course of a semester. Here again, you can use Access to create the structure, export the table to an XML document, and use the output on a simple Web site that can be updated when needed. · You need to capture survey data from non-networked, remote locations within your organization. Each site maintains a local Web site, but the locations are locked down and have limited net- working abilities. You might create a master Access database that will store the data collected from the remote sites. You export your table structure to XML and send the output to the remote locations for use in capturing the survey data. The remote locations then send the updated .xml file back to you for importing into the master Access database and for analysis. In each of these cases, the XML document serves to capture as well as present data. A schema is needed to preserve the structure and integrity of the data that is being entered. We'll look more closely at how this works in the next section. Just the Steps Export an Access table to XML 1. 2. 3. 4. Open a table in an existing database. On the File menu, click Export. In the Save As Type drop-down list, select XML. Select the path to which you want to save the .xml files, and click Export All.