473,509 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert xml to an access database

Hi

I am fairly new to VBA and want to know how I can convert or I mean
parse the XML file and convert to an access database.

Please help. I greatly appreciate your time and help.
I would be glad to have ur answers ASAP.

Thanks a lot

Nov 13 '05 #1
1 6145
Add a reference to Microsoft XML v 3.0 (MSXML3.DLL) to your project.
This will give you access to the XML Document object model (DOM). Load
the XML Document and loop through the nodes in it. Write a record for
each node as appropriate. A sample (unchecked and without error
trapping) is below.

Bill E.
Hollywood, FL

'--------xml document-------------
<?xml version="1.0" encoding="utf-8"?>
<newsgroup name="rec.kites" lastnr="146104">
<article>
<nr>142980</nr>

<aid>&lt;rN***********************@news-text.cableinet.net&gt;</aid>
<references></references>
<from>"Bandulu" &lt;ba*****@REMOVETHISdarkdigital.org&gt;</from>
<date>4/19/2003 10:45:43 AM</date>
<subject>Re: Line Laundry in UK</subject>
</article>
<article>
<nr>142977</nr>
<aid>&lt;b7************@ID-17525.news.dfncis.de&gt;</aid>

<references>&lt;MP************************@news.ci s.dfn.de&gt;</references>
<from>"David Brown :o\)" &lt;ne**@parkcourt.co.uk&gt;</from>
<date>4/18/2003 11:49:29 PM</date>
<subject>Re: At last, a decent pic!</subject>
</article>
</newsgroup>
'----------------------------------
Sub ReadXMLDocument()
Dim strPath as String
Dim oXMLDocument As New MSXML2.DOMDocument
Dim oDocElement As MSXML2.IXMLDOMElement
Dim oNode As IXMLDOMNode

strPath="Enter the path to the Xml Document"

oXMLDocument.Load strPath
Set oDocElement = oXMLDocument.documentElement

'Loop through the top level nodes in the XML document
'Add a record for each one
For Each oNode In oDocElement.childNodes
AddArticle oNode.childNodes(0).Text, oNode.childNodes(1).Text,
oNode.childNodes(2).Text, oNode.childNodes(3).Text,
oNode.childNodes(4).Text, oNode.childNodes(5).Text
Next

Set oNode = Nothing
Set oDocElement = Nothing
Set oXMLDocument = Nothing
End Sub

Function AddArticle(strNr As String, strAID As String, strRef As
String, strFrom As String, strDate As String, strSubject As String)
'Add a record to the articles table tblArticles
Dim strSQL As String

strSQL="INSERT INTO tblArticles (Nr, Aid, References, From, Date,
Subject) "
strSQL=strSQL & "VALUES ('" & strNr & "', '" & strAID & "', '" &
strRef & "', '" & strFrom & "', #" & strDate & "#, '" & strSubject &
"')"
DoCmd.SetWarnings False
DoCmd.RunSQL (strSQL)
DoCmd.SetWarnings True
End Function

Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7677
by: Gary Dale | last post by:
I have a database that was originally set up in Access 97 (because that was what we had in the office). We had a copy of Access 2000 set up on one machine for a brief period to get at another...
25
4342
by: cory | last post by:
Hi, I have an Access database and am having an ASP.NEt application written for it. It is almost complete. I have a hosting company that I signed up with a month ago but before I did anything I...
12
2183
by: dixie | last post by:
Can someone familiar with Access 2003 please answer this question? I am asking because I don't have the use of A2003. When Access 2003 finds an Access 2000 database, does it come up with some...
3
2399
by: Dori | last post by:
hi, trying to convert access 97 to access 2003 with the access 2003 convertion tool of microsoft, but the only thing that isn't convert is the modules in the vb of access 97. what should i...
3
2673
by: ET | last post by:
I don't know whats the problem, but after I added functions to first verify, then relink linked tables if not found, now I can't convert that database to MDE format. I can split the database, but...
3
2862
by: Jon S via DotNetMonster.com | last post by:
Hi all, Is there a way to convert an Access.mdb from one format (say Access '97 or Access 2000) to Access 2002 format using ADO.NET and C#??? I know how to do it manually using the Access DBMS...
3
12917
by: Bill Nicholson | last post by:
What tools are available to convert Access projects (Forms, Code, Queries, Reports) to VB Dot Net? Does anyone have experience with this type of conversion? Please tell me I don't have to do it...
2
1264
by: Mamatha | last post by:
Hi I want to convert SQLServer database into MS-Access through ASP program.Is there any possiblity to covert?If possible please let me know and thanks in advance. Mamatha
5
2554
by: melickas | last post by:
We designed a custom application using Office Developer Tools '97 which included a Run-time version of Access--- so it would not matter if our customer even had any version of Access on their...
6
2212
by: tombsy | last post by:
Hello Group. I work for a company who is about to embark on a long awaited Office upgrade from Office 97 to Office XP. Office XP comes with Access 2002. I am an accomplished Access developer...
0
7233
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7410
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7067
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.