Does anyone know why I keep getting this error - 'Property let procedure not defined and property get procedure did not return an object' , for the code below, it seems to have occured since I added the line ' xmlDom.preserveWhiteSpace = True', thanks for any help.
code:--------------------------------------------------------------------------------
Option Compare Database
Private xmlDom As MSXML2.DOMDocument
Function initiateXML(filePath As String)
On Error GoTo Err_Xml
Set xmlDom = New MSXML2.DOMDocument
xmlDom.async = False
xmlDom.preserveWhiteSpace = True
isLoaded = xmlDom.Load(docPath)
Exit_Xml:
Exit Function
Err_Xml:
MsgBox Err.Description
Resume Exit_Xml
End Function
Function parseXML(nodeName As String, parentNodeName As String, tableName As String)
On Error GoTo Err_Xml
Dim nList As MSXML2.IXMLDOMNodeList
Set nList = xmlDom.selectNodes("//" & parentNodeName)
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
'Create connection
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentDb.Name & ";"
'Create new recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM " & tableName, conn, adOpenKeyset, adLockOptimistic
'MsgBox "table name = " & tableName
'Loop through each node and it's children, then add that node to the recordset
For Each xmlNode In nList
For Each outerChild In xmlNode.childNodes
rs.AddNew
For Each child In outerChild.childNodes
rs.Fields(child.nodeName) = child.Text
'MsgBox "nodeName = " & child.nodeName
Next
rs.Update
Next
Next
'Clean up
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
Set nList = Nothing
Set xmlNode = Nothing
Exit_Xml:
Exit Function
Err_Xml:
MsgBox Err.Description
Resume Exit_Xml
End Function
code:--------------------------------------------------------------------------------
Option Compare Database
Private xmlDom As MSXML2.DOMDocument
Function initiateXML(filePath As String)
On Error GoTo Err_Xml
Set xmlDom = New MSXML2.DOMDocument
xmlDom.async = False
xmlDom.preserveWhiteSpace = True
isLoaded = xmlDom.Load(docPath)
Exit_Xml:
Exit Function
Err_Xml:
MsgBox Err.Description
Resume Exit_Xml
End Function
Function parseXML(nodeName As String, parentNodeName As String, tableName As String)
On Error GoTo Err_Xml
Dim nList As MSXML2.IXMLDOMNodeList
Set nList = xmlDom.selectNodes("//" & parentNodeName)
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
'Create connection
Set conn = New ADODB.Connection
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentDb.Name & ";"
'Create new recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM " & tableName, conn, adOpenKeyset, adLockOptimistic
'MsgBox "table name = " & tableName
'Loop through each node and it's children, then add that node to the recordset
For Each xmlNode In nList
For Each outerChild In xmlNode.childNodes
rs.AddNew
For Each child In outerChild.childNodes
rs.Fields(child.nodeName) = child.Text
'MsgBox "nodeName = " & child.nodeName
Next
rs.Update
Next
Next
'Clean up
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
Set nList = Nothing
Set xmlNode = Nothing
Exit_Xml:
Exit Function
Err_Xml:
MsgBox Err.Description
Resume Exit_Xml
End Function