INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Search an XML document for a specific vaule and the delete or move the file

Search an XML document for a specific vaule and the delete or move the file

Search an XML document for a specific vaule and the delete or move the file

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close