itsrainman
Technical User
Hi
I'm pretty new to the VB scripting language but have been able to plod along and get a few things done, but I'm not stumped??
I have an XML file which when copies into the sourcedir should be acted upon but it is not!
<?xml version="1.0" encoding="UTF-8"?>
<InstrumentDetails>
<InstrumentCalibrationDate>24-May-2012</InstrumentCalibrationDate>
<SerialNo>12</SerialNo>
</InstrumentDetails>
<EquipmentSummary>
<CalibrationPassed>1</CalibrationPassed>
<EquipmentSummary>Unit calibrated all ok. No problems encountered.</EquipmentSummary>
</EquipmentSummary>
I have an XML file details below, which monitors the sourcedir for files and either moves them or deletes them dependent upon the value of CalibrationPassed. Now I now It's opened the correct file as my message box displays it but it does not seem to read any values from the XML file which is why I think the file is not moved or deleted.
Any Help would be fantastic.
sourceDir = ("c:\PPCC\Files\In")
backupDir = ("c:\PPCC\Files\Out")
Set xmlDoc = CreateObject( "Microsoft.XMLDOM" )
xmlDoc.Async = "False"
Set xPE = Nothing
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set oXml=CreateObject("Msxml2.DOMDocument.3.0")
oXml.async= Flase
'Set oXml = CreateObject("Msxml2.DOMDocument")
' oXml.async = False
Set FLD = FSO.GetFolder(sourceDir)
'Loop through the folder And Get the file names
For Each Fil In FLD.Files
FileName = Fil.Name
TotalFile = sourceDir & "\" & FileName
oXml.load(TotalFile)
Set SerialNo = oXml.selectSingleNode("InstrumentInfo:SerialNo")
Set CalibrationPassed = oXml.selectsinglenode ("//CalibrationPassed")
MsgBox "Hello There!" & TotalFile
If CalibrationPassed = 1 Then
Set fso = CreateObject( "Scripting.FileSystemObject" )
sSerialNo = sourceDir & "\iCAM" & SerialNo & ".XML"
If (fso.FileExists(sSerialNo)) Then
fso.DeleteFile sSerialNo
Else
fso.MoveFile sSerialNo, backupDir
End If
End If
Next
I'm pretty new to the VB scripting language but have been able to plod along and get a few things done, but I'm not stumped??
I have an XML file which when copies into the sourcedir should be acted upon but it is not!
<?xml version="1.0" encoding="UTF-8"?>
<InstrumentDetails>
<InstrumentCalibrationDate>24-May-2012</InstrumentCalibrationDate>
<SerialNo>12</SerialNo>
</InstrumentDetails>
<EquipmentSummary>
<CalibrationPassed>1</CalibrationPassed>
<EquipmentSummary>Unit calibrated all ok. No problems encountered.</EquipmentSummary>
</EquipmentSummary>
I have an XML file details below, which monitors the sourcedir for files and either moves them or deletes them dependent upon the value of CalibrationPassed. Now I now It's opened the correct file as my message box displays it but it does not seem to read any values from the XML file which is why I think the file is not moved or deleted.
Any Help would be fantastic.
sourceDir = ("c:\PPCC\Files\In")
backupDir = ("c:\PPCC\Files\Out")
Set xmlDoc = CreateObject( "Microsoft.XMLDOM" )
xmlDoc.Async = "False"
Set xPE = Nothing
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set oXml=CreateObject("Msxml2.DOMDocument.3.0")
oXml.async= Flase
'Set oXml = CreateObject("Msxml2.DOMDocument")
' oXml.async = False
Set FLD = FSO.GetFolder(sourceDir)
'Loop through the folder And Get the file names
For Each Fil In FLD.Files
FileName = Fil.Name
TotalFile = sourceDir & "\" & FileName
oXml.load(TotalFile)
Set SerialNo = oXml.selectSingleNode("InstrumentInfo:SerialNo")
Set CalibrationPassed = oXml.selectsinglenode ("//CalibrationPassed")
MsgBox "Hello There!" & TotalFile
If CalibrationPassed = 1 Then
Set fso = CreateObject( "Scripting.FileSystemObject" )
sSerialNo = sourceDir & "\iCAM" & SerialNo & ".XML"
If (fso.FileExists(sSerialNo)) Then
fso.DeleteFile sSerialNo
Else
fso.MoveFile sSerialNo, backupDir
End If
End If
Next