Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
x=FileGet("dafile.xml") x=StrReplace("Old stuff","New Stuff") FilePut("dafile.xml",x)
and
; This works for me Winbatch 2002G and uses the SDK... ;The name of the file is user_settings.xml (attached). I want to ;change the line PROPERTY NAME="SD SERVER" kdchrt01 /PROPERTY to ;PROPERTY NAME="SD SERVER" kdcitc01 /PROPERTY I am familiar with ;editing a private INI file and making registry changes with WinBatch ;but I can not find info on editing or creating a XML file. #definefunction SetData(str, value, file) Doc = objectopen("Msxml2.DOMDocument.4.0") Doc.async = @false Doc.load(file) dNode = doc.selectsingleNode(strcat("//", str)) dNode.text = value Doc.save(file) objectclose(dNode) objectclose(Doc) return #endfunction #definefunction GetData(str, file) Doc = objectopen("Msxml2.DOMDocument.4.0") Doc.async = @false Doc.load(file) dNode = doc.selectsingleNode(strcat("//", str)) retstr = dNode.text objectclose(dNode) objectclose(Doc) return(retstr) #endfunction xfile = "C:\Test\Stan\user_settings.xml" oldvalue = "kdchrt01" newserver = "kdcitc01" ; specify a search string to return the correct node... searchstr = "SETTINGS/GROUP[@NAME='ACCOUNTS']/GROUP[@NAME='1']/PROPERTY[@NAME='SD SERVER']" ; show the old value... message("Debug", GetData(searchstr, xfile)) ; set the new value... SetData(searchstr, newserver, xfile) ; show the new value... message("Debug", GetData(searchstr, xfile)) exit
Article ID: W16150
File Created: 2014:07:18:09:51:38
Last Updated: 2014:07:18:09:51:38