O'Reilly logo

Beginning Access™ 2007 VBA by Denise Gosnell

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

7.6. XML Files

XML stands for eXtensible Markup Language. You have likely heard the XML buzzword, but you may not know what XML files really are. XML is a syntax that enables systems to create simple text documents with various tags that identify how the text should be interpreted. At the end of this section, you will create an XML document from a table so that you can see what one looks like.

The idea behind XML is to give various types of operating systems on different platforms a meaningful way of communicating with one another. As the use of XML has grown in popularity, the need to write Access applications that can import and export to XML text files has increased. Recent versions of Microsoft products incorporate extended XML functionality, including the ImportXML and ExportXML methods that Access provides to enable users to import from and export to XML databases. You will now look at each of these in turn.

The syntax for the ImportXML method is:

Application.ImportXML DataSource, ImportOptions

The DataSource is the name and path of the XML file to import. The ImportOptions parameter can be acStructureAndData (default), acAppendData, or acStructureOnly. Thus, to import an XML document into a table in your Access database, you might use the following code:

Application.ImportXML "employees.xml", acStructureAndData

The ExportXML method allows you to export data in your Access database to XML files to exchange data with other applications. Here is the syntax:

Application.ExportXML ...

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