On the line of code that says: oDoc.loadfile mFile, QTP stops running with an error that says the file is not formatted correctly. I expect some of the XML to be formatted wrong. I do not want the function to stop so I'm considering putting On Error Resume Next and Orn Error GoTo 0 around it.
What do I check for to know if the file loaded into the oDoc object successfully. Can I check the err object for a non zero value?
I thought that I have seen that the loadfile method sets a property saying if it passed or not. I Googled for this. I cannot find it now.
Set oDoc = XMLUTIL.CreateXML()
On Error Resume Next
oDoc.loadfile mFile <--- I want to catch the error here before QTP says file not formatted correctly.
On Error GoTo 0
Set oRoot = oDoc.GetRootElement()
'The next line is just to see the root value while tracing code.
mRoot = oRoot.ElementName
Set chldrn = oRoot.ChildElementsByPath(strElementPath) ' Note: Changed 10/19/2012. Function usage changed.
If chldrn.count = 0 Then
RetElementExists = False
RetElementExists = True
' Empty the before using it.
For i = 1 to chldrn.count
ReDim Preserve aRestValue(i)
aRestValue(i - 1) = chldrn.item(i).value
Set oDoc = Nothing
Set chldrn = Nothing