I am using the code below to parse thru several XML files and print out data from each XML file. It only looks for files that starts with BEX and that are older than 2 days. However the code does not run if there are more than one file to parse. At that point I get the error -- VBSCript runtime error: Object required:'ElemList.item(...)'
But it runs fine if there is only one file to parse. I think the error is caused by the array not incrementing (see "server = ElemList.item(0).Text" in the code below ).
But I am not really sure - would appreciate any advice.
TIA
But it runs fine if there is only one file to parse. I think the error is caused by the array not incrementing (see "server = ElemList.item(0).Text" in the code below ).
But I am not really sure - would appreciate any advice.
TIA
Code:
Dim server, filepath
Dim fso,fold,fil,XMLDoc
Set fso = CreateObject("Scripting.FileSystemObject")
Set fold = fso.GetFolder("C:\Program Files\Symantec\Backup Exec\Data")
For each fil in fold.files
if (DateDiff("d",Now,fil.DateCreated) < 0) And (UCase(Left((fil.Name),3)) = "BEX") Then
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
fil = fold & "\" & fil.name
wscript.echo fil
xmlDoc.load(fil)
Set ElemList = xmlDoc.getElementsByTagName("jobServer")
server = ElemList.item(0).Text
Wscript.Echo server
Set ElemList = xmlDoc.getElementsByTagName("timeStart")
start_time = Replace(ElemList.item(0).Text,"Job started:","")
Wscript.Echo start_time
Set ElemList = xmlDoc.getElementsByTagName("timeEnd")
end_time = Replace(ElemList.item(0).Text,"Job ended:","")
Wscript.Echo end_time
Set ElemList = xmlDoc.getElementsByTagName("completeStatus")
engine_completion_status = Replace(ElemList.item(0).Text,"Job completion status:","")
Wscript.Echo engine_completion_status
End if
Next