Hi friends,
I need to transform data from XML & store in a ACCESS Table,
I have a code which displays the msgs as msgbox,but I need to insert in a table.I used XML4 here.I am relatively new to VB6 XML.Can someone tel me how to do it or provide a sample code.I Need it urgently for my proj

'We make use of XML4 here
Dim objDOM As DOMDocument40
Private Sub Command1_Click()
Dim ndPerson As IXMLDOMNode
'IXMLDOMNode & DOMDocument40 are classes of MSXML2
Set ndPerson = objDOM.selectSingleNode("/ATM") 'contains root
MsgBox ndPerson.Text
Set ndPerson = Nothing

End Sub

Private Sub form_load()
  Set objDOM = New DOMDocument40
  If Not objDOM.Load("person.xml") Then
    MsgBox "Did not load person.xml because " & objDOM.parseError.reason
    Exit Sub
  End If
End Sub

here,person.xml is name of xml file.

Recommended Answers

All 4 Replies

Hi,i hav following code which I used in module modmain but I am getting an error saying "could not find installable ISAM".

Public g_ConDB As ADODB.Connection
Public g_domXML As DOMDocument40
Public g_rsFaults As Recordset

Public Sub Main()
End Sub

Public Sub ConnectDB()

  Set g_ConDB = New Connection
  g_ConDB.Open "provider = Microsoft.Jet.OLEDB.4.0; datasource = F:\xml2test\db1.mdb"
End Sub

Public Sub LoadXML()
  Set g_domXML = New DOMDocument40
  g_domXML.Load "F:\xml2test\MS1.xml"
End Sub

Public Sub OpenRS()
  Set g_rsFaults = New Recordset
  g_rsFaults.LockType = adlockpesimistic
  Set g_rsFaults.ActiveConnection = g_ConDB
  g_rsFaults.Open "Select * from xyz"

End Sub

Public Sub AddFaultRecords()
  Dim ndFault As IXMLDOMNode
  Dim lngMachineID As Long
  Dim FaultID As String
  Dim dtDate As Date
  Dim strTime As String
  For Each ndFault In g_domXML.selectNodes("/MACHINE")
    lngMachineID = Val(ndFault.selectSingleNode("ID").Text)
    FaultID = ndFault.selectSingleNode("FAULTID").Text
    dtDate = CDate(ndFault.selectSingleNode("DOO").Text)
    strTime = ndFault.selectSingleNode("TOO").Text

    g_rsFaults.findfirst "[machine id]=" & lngMachineID & " and [Fault id]='" & FaultID & "'"
    If g_rsFaults.EOF Then
      g_rsFaults("Machine ID") = lngMachineID
      g_rsFaults("Fault ID") = FaultID
    End If

    g_rsFaults("Date Of Occurence") = dtDate
    g_rsFaults("Time of Occurence") = strTime
  Next ndFault

End Sub
Private Sub CloseRS()
End Sub
Private Sub CloseDB()
End Sub

I used start mode from submain & used Microsoft Active DAta Objects (2.6) & msxml4

I am not familiar with XML2VB stuff & I got coding from net.I dont know wat is wrong with the code...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.