Code:
Public Function xXML(Filepath As String) As Object()
Set objParser = CreateObject("Microsoft.XMLDOM")
Set OCC = "OMICRON CONTROL Center"
Dim xDoc As MSXML2.DOMDocument
Dim NodeList As IXMLDOMNodeList
Dim Node As MSXML2.IXMLDOMElement
Dim ObjTempArray(40) As Object
Set xDoc = New MSXML2.DOMDocument
'Prooves whether the document is a valid XML Document.
xDoc.validateOnParse = True
'DTD = Document Type Definition
If xDoc.load(Filepath) = False Then
MsgBox ("Unable to load File.",vbExclamation,OCC)
Else
MsgBox(Filepath+" succesfully loaded!",vbInformation,OCC)
StartAutomation = MsgBox ("Start Test-Automation?",vbOkCancel,OCC)
If StartAutomation = vbCancel Then
MsgBox("Test-Automation canceled.",vbInformation,OCC)
Else
'Reading the *.cid file
MsgBox("Automation Start!",vbInformation,OCC)
' Set NodeList = xDoc.documentElement.selectNodes("//catalog/book/author")
Set NodeList = xDoc.documentElement.selectNodes("//SCL/IED/AccessPoint/Server/LDevice/LN")
For Each Node In NodeList
NodeType = Node.getAttribute("lnClass")
If NodeType = "PTOC" Then
'Name of array is PTOC
Dim PTOC(2) As Double
PTOC(0) = 1
PTOC(1) = 1
PTOC(2) = 1
ObjTempArray(0) = PTOC
MsgBox("Yes")
End If
Next
xXML = ObjTempArray
x = NodeList.length
MsgBox(x)
End If
End If
End Function
i got an error when trying to set the first element of the objtemparray( ObjTempArray(0) = PTOC)
The Error is: Object var is 'Nothing'
I m trying for an hour now and cant guess of my mistake, if anyone can tell me where my mistake is i would be very thankful. :-)
best regards
Sascha