RE: About xml



And what is better: my import method or to use with:
==================================
Dim objDomDoc As New DOMDocument
objDomDoc.async = False
objDomDoc.Load sFullPath
==================================
Dim xmlDoc
Set xmlDoc = CreateObject("MSXML2.DOMDocument")
xmlDoc.async = False
xmlDoc.validateOnParse = True
success = xmlDoc.Load(sFullPath)==================================



"yael" wrote:

Hi,
How can I create/write into xml file from vba + access 2003?
This code read from xml file into the form.
every form control = element in the xml (names)
the xml file with 1 level.

Public Sub ImportToXML(sFullPath As String, frm As Form)
On Error Resume Next

'XML DOM objects
Dim objDomDoc As New DOMDocument
Dim sName As String
Dim sCtrlName As String
Dim value As Variant
Dim size As Long
Dim index As Long
Dim ctrl As Control

'Open DOM object by loading the xml file.
objDomDoc.async = False
objDomDoc.Load sFullPath

size = objDomDoc.documentElement.childNodes.length
For index = 0 To size
sName = objDomDoc.documentElement.childNodes.Item(index).baseName
value = objDomDoc.documentElement.childNodes.Item(index).nodeTypedValue
For Each ctrl In frm.Controls
sCtrlName = UCase(ctrl.name)
If sCtrlName = sName Then
ctrl = value
End If
Next
Next index

Set objDomDoc = Nothing
End Sub

<?xml version="1.0" encoding="UTF-8"?>
<ONE_USER>
<CONTACT_TYPE_ID>4</CONTACT_TYPE_ID>
<JOB_COMMITTEE>1</JOB_COMMITTEE>
<PROFESSION_ID>2</PROFESSION_ID>
<LOGIN>3</LOGIN>
<SITE_ID>4</SITE_ID>
<DIVISION>5</DIVISION>
<FIRST_NAME>6</FIRST_NAME>
<LAST_NAME>7</LAST_NAME>
<TITLE>8</TITLE>
<ACADEMIC_TITLE>9</ACADEMIC_TITLE>
<DEPARTMENT_SITE_ID>10</DEPARTMENT_SITE_ID>
<TITLE_ID>11</TITLE_ID>
<CERTIFICATION_DATE>12</CERTIFICATION_DATE>
<QUALIFICATION>13</QUALIFICATION>
<ID_NUMBER>14</ID_NUMBER>
<PHONE>15</PHONE>
<FAX>16</FAX>
<MOBILE>17</MOBILE>
<EMAIL>18</EMAIL>
</ONE_USER>

Thank's,
Yael.



.



Relevant Pages

  • Re: problem with xml component(s)
    ... Tony Proctor wrote: ... All it does is open an xml file. ... Set xmlDoc = New MSXML2.DOMDocument30 ... If Not IsOk Then ...
    (microsoft.public.vb.general.discussion)
  • Problem with script execution
    ... set xmlDoc = CreateObject ... Then all works OK and I get the contents of the XML file. ... I have installed the MSXML4 and the Internet Explorer tools. ...
    (microsoft.public.windows.inetexplorer.ie6.setup)
  • problem with xml component(s)
    ... I have a component that runs fine on a server, ... All it does is open an xml file. ... Set xmlDoc = New MSXML2.DOMDocument30 ... If Not IsOk Then ...
    (microsoft.public.vb.general.discussion)
  • Value of Type String cannot be converted to System.xml.xmlDocument
    ... Using Visual Studio 2008 Professional trying to read an xml file and assign the value to a variable so that I can pass the variable as an XML document to another function. ... The code below tells me that I cannot convert a type string to a system.xml.xmldocument. ... Dim xmldoc As New Xml.XmlDocument ...
    (microsoft.public.vsnet.vstools.office)
  • Re: load xml file containing header line
    ... Atara scripsit: ... > I use the following code to load xml file: ... > Dim XmlDoc As New Xml.XmlDocument ...
    (microsoft.public.dotnet.languages.vb)