Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-30-2008, 09:06 AM
AnA AnA is offline
Junior Member
 
Join Date: Jul 2008
Posts: 2
AnA is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Replace value in file

Hi guys,

after executing the following script in order to find and replace certain value in web.config, the value in the file is not being modified! "WScript.Echo "ORIGINAL VALUE: " & orig_val.value" outputs the current value correctly, i.e. I do approach the value as should...

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
Set ConfigDoc = CreateObject("Msxml2.DOMDocument.3.0")
ConfigDoc.async = False
ConfigDoc.preserveWhiteSpace = True
Dim strXMLFile
strXMLFile = "C:\web.config"
' If the file is Read-Only
'then change that in order to edit
Set f = objFSO.GetFile(strXMLFile)
IF f.attributes and 1 Then
f.attributes = f.attributes - 1
End IF

IF ConfigDoc.Load(strXMLFile) Then
ConfigDoc.setProperty "SelectionLanguage", "XPath"
Set AppSettings = ConfigDoc.selectSingleNode("configuration/appSettings")
IF Not AppSettings Is Nothing Then
Set orig_val = AppSettings.selectSingleNode("add[@key = 'MyKey']/@value")
IF Not orig_val Is Nothing Then
WScript.Echo "ORIGINAL VALUE: " & orig_val.value
orig_val.value = "NewVal"
End IF
End if
End if

can you please help , since I am lost :-(
Thanks in advance
Ana
Reply With Quote

This ad is part of our Revenue Sharing program
  #2 (permalink)  
Old 07-31-2008, 07:44 AM
AnA AnA is offline
Junior Member
 
Join Date: Jul 2008
Posts: 2
AnA is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default To whoever is interested in solution :-)

I was missing one line after orig_val.value = "newVal"

--> ConfigDoc.save(strXMLFile)
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Vbscript - Regular Expression to find and replace data with an exclude parameter DeeCee3ee ASP & VBScript Forum 0 07-21-2008 07:11 PM


All times are GMT. The time now is 06:38 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30