Forum Moderators: open

Message Too Old, No Replies

Reading web.config through script

Reading web.config through script

         

dsathish

7:09 pm on Sep 18, 2009 (gmt 0)

10+ Year Member



Hi

I am trying to read the web.config through vbscript and trying edit the values of the web.config through vbscript again, but I am not to read and write the values, below is the piece of code, can some one please help

Thank you

Sathish Kumar D

X = MsgBox(" Do you want to update the current version of Portfolio in XLeRate?",vbYesNo)
If X = vbYes Then

XLeRateVersionNO = InputBox("Enter the XLeRate Version no. in which you want to update the Portfolio version")

ConfigFilePath = ServerPath1 & "\PricingSystme\XLeRate\"& XLeRateVersionNo &"\XLeRateServer\web.config"
LogToFile(ServerPath1 & "\PricingSystme\XLeRate\"& XLeRateVersionNo &"\XLeRateServer\web.config")


Set objXML = CreateObject("MSXML2.DOMDocument")
objXML.Async = False
objXML.Load(ConfigFilePath)


Set node = objXML.documentElement.selectSingleNode("/configuration/WCFServiceClient/ApplicationInformation/Applications/Application/Environments/Environment/Address")

' If node is nothing Then
' LogToFile("PortfolioService does not exist")
' Else
node = PortfolioURL
'End If

objXML.Save ServerPath1 & "\PricingSystme\XLeRate\"& XLeRateVersionNo &"\XLeRateServer\web.config"

Else

LogToFile("We are not updating the RefData with new Portfolio Version")

End if
End if

Ocean10000

1:12 am on Sep 19, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think if I understand your question. Is that if the portion of the webconfig doesn't exist you do nothing. And you will only update the web.config if you find it has a value you wish to change.

And welcome to WebmasterWorld.

[Code below]
If node is nothing Then
'Do Nothing Node Doesn't Exist
Else
'Replace node with updated Node Information.
'
'Update Node Code Goes Here

'Only need to save it if there is a change I assume.
objXML.Save ServerPath1 & "\PricingSystme\XLeRate\"& XLeRateVersionNo &"\XLeRateServer\web.config"
End If

dsathish

5:32 pm on Sep 21, 2009 (gmt 0)

10+ Year Member



Yes absolutely you are correct, I want to edit url which is inside the web.config, whenever I do a release for other application, hope you understands now