Hi all,

Can someone please point me in the write direction with a .vbs which can find the value in an .xml file and replace the value then save the file. I have found a few examples but none seem to work for my case due to the node I'm trying to modify I guess.

Example: In the below example code I'm trying to change the value of Br4nchNumb3r to PASSED

<?xml version="1.0" encoding="utf-8"?>
    <Branch BranchID="Br4nchNumb3r" />
<!--SYD Board I -->
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

d3souzaAuthor Commented:
I found a solution that works.  Shared to help others.

Dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")

If (objFSO.FileExists("c:\temp\RateBoardConfig.xml")) Then
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8

Dim textToReplace
Dim textReplacement
textToReplace = "Br4nchNumb3r"
textReplacement = "NEW VALUE HERE"

Set objFile = objFSO.OpenTextFile("c:\temp\BoardConfig.xml", ForReading)
strText = objFile.ReadAll
strNewText = Replace(strText, textToReplace, textReplacement)

Set objFile = objFSO.OpenTextFile("c:\temp\BoardConfig.xml", ForWriting)
objFile.WriteLine strNewText

Dim errorFileSys, errorLogTxt

Set errorFileSys = CreateObject("Scripting.FileSystemObject")
Set errorLogTxt = errorFileSys.OpenTextFile("C:\temp\BoardConfig.log", ForAppending, True) 
errorLogTxt.WriteLine(Now &"     urlsinfo.xml file did not exist in directory C:\. ")

End If

'Exit Script

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.