XML & Access

shay

Registered User.
Local time
Today, 16:46
Joined
Apr 29, 2002
Messages
169
Hi all

I've done a quick search and read that you can import XML files in Access XP and Access 2003. Can you do this with any other versions?

TIA

shay :cool:
 
Absolutely, you can import XML files in Access 97 and up, for sure. Here's an example which runs just fine under Access 97:

Create a new form (frmXML, for example) and add a textbox (txtXML) and a Command Button (cmdLoad). Then add the following code to the form's code window:
Code:
Private Sub cmdLoad_Click()
    Dim xmlDoc
    Dim xmlError
    Dim xmlRootElement
    Dim success As Boolean

    Set xmlDoc = CreateObject("MSXML2.DOMDocument")

    ' Allow the document to complete loading
    xmlDoc.async = False
    ' Validate the document against a DTD
    xmlDoc.validateOnParse = True
    success = xmlDoc.Load("http://www.juicystudio.com/tutorial/xml/cd.xml")
    If success = True Then
        Set xmlRootElement = xmlDoc.documentElement
        Me.txtXML = xmlRootElement.XML
        Set xmlRootElement = Nothing
    Else
        Set xmlError = xmlDoc.parseError
        Me.txtXML = "Error code: " & xmlError.errorCode & vbCrLf _
                   & "Reason: " & xmlError.reason & vbCrLf _
                   & "Source: " & vbCrLf & xmlError.srcText & vbCrLf _
                   & "URL: " & xmlError.url
        Set xmlError = Nothing
    End If
End Sub

Save the form and try it out. See if it works for you.
 
ByteMyzer

Thanks very much. It was good to see a working example.

Thanks again

shay
 
Is there any way to just pullup certian tags in the XML file? For example, I have a XLM file with a tag like this:

<LBody id="LinkTarget_1493">1.03.7 Page Layout (Margins)</LBody>
</LI>
</L>
<Normal>As we will utilize printed paper manuals, text will be printed on the front and back of each page and inserted into binders. The margins will be set to allow for hole punching that will not encroach onto the text.</Normal>

How do I retrieve that specific tag?

thanks
 

Users who are viewing this thread

Back
Top Bottom