Use XML files with MS Access

The eXtensible Markup Language, XML, is a simple text-based language with which some tags are created in a regular text-based document.

The document can be created using any regular text editor such as Notepad in Microsoft Windows.
The document must be saved as a computer file with the .xml extension. Once the document is created and the file has been saved, any application that needs that file can use it. Based on this, there are some characteristics to an XML file:

  • The document can be created using any text editor
  • The content of the document is made of ASCII text that consists of small things (formats) named tags
  • The tags in the document must follow some rules
  • The whole content must be structured a certain way, referred to as well-formed. In other words, an XML document that follows the XML standards is said to be well-formed
  • The document does not indicate what it is used for. The application that uses that file must know what to do with the file

Based on this, XML makes it possible to create a document that various types of applications can use. For example, you could have various database environments that have different ways to create and manage their records. Imagine you have a table of customers or products in one of the databases and you want other databases to use or even update the list of customers or products. To make those databases environments communicate, you can create an XML file that contains information about the customers or products. Then, any of those database environments can access that document and do whatever it wants, such as adding new records or updating existing records. This can be illustrated as follows:

xml1

Creating an XML File in Microsoft Access

To create an example file in Microsoft Access, you have four primary options, ranging from ridiculously easy to a little complex. The first thing to know is that Microsoft has done an incredibly efficient work in XML, not only in Microsoft Access but throughout the Microsoft Windows family of operating systems. For example, it is so easy to create an XML file in Microsoft Access without writing a single line of code.

The four options to use XML in Microsoft Access are:

  • Visually importing and/or exporting XML
  • Using File Processing to manually create an XML document and file
  • Using the Application class
  • Using the MSXML library

Each one of those options has its advantages and disadvantages.

One of the basic ways to view an XML document is to open it in a Web browser.

you can use Microsoft XML Core services in your Microsoft Access project as follows :

references6aSample code for Opening an XML File :

Private Sub Command0_Click()
    Dim docXMLDOM As DOMDocument

    If Dir("ContractWorkers.xml") = "" Then
        docXMLDOM.loadXML ""

        docXMLDOM.Save "ContractWorkers.xml"
    Else
        docXMLDOM.Load "ContractWorkers.xml"
    End If

    Set docXMLDOM = Nothing
End Sub

 

extradrmtech

Since 30 years I work on Database Architecture and data migration protocols. I am also a consultant in Web content management solutions and medias protecting solutions. I am experienced web-developer with over 10 years developing PHP/MySQL, C#, VB.Net applications ranging from simple web sites to extensive web-based business applications. Besides my work, I like to work freelance only on some wordpress projects because it is relaxing and delightful CMS for me. When not working, I like to dance salsa and swing and to have fun with my little family.

You may also like...