O'Reilly logo

Office 2003 XML by Evan Lenz, Mary McRae, Simon St. Laurent

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required