Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I'm a freelance consultant, and your site's helped me with many issues. I just wanted you to know that someone does appreciate the intelligent help your site offers."

Geography

Where in the world do Tek-Tips members come from?

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

itsrainman (TechnicalUser)
30 May 12 18:40
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

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!

Back To Forum

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