Automating XML Import and Export

While the GUI is certainly the most flexible way to learn about Access’ XML support, it can be tricky to explain if you’re using XML to distribute information to users or collect information from them. Rather than tell users to go through a multi-step process, you can use the Visual Basic for Applications Application.ImportXML and Application.ExportXML methods to create buttons or other interfaces that let users get information in and out more easily.

Of the two methods, Application.ImportXML is by far the simpler. It only takes two argument: a data source—most likely a file reference or a URL—and an options constant. The choices for the options are acAppendData, acStructureAndData (the default), and acStructureOnly. These correspond to the behaviors described in Section 8.3.

For an example of how this might work, the XML in Example 8-15 is available at http://simonstl.com/ora/updateBook.xml.

Example 8-15. An online XML update file

<update> <books> <ISBN>0596003722</ISBN> <Title>XSLT Cookbook</Title> <Tagline>Solutions and Examples for XML and XSLT Developers</Tagline> <Short_x0020_Description>A comprehensive collection of recipes for applying XSLT in a variety of situations.</Short_x0020_Description> <Long_x0020_Description>A comprehensive collection of recipes for applying XSLT in a variety of situations, including structural changes, and conversion to XHTML, SVG, and programming code.</Long_x0020_Description> <PriceUS>34.95</PriceUS> </books> ...

Get Office 2003 XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.