Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

modify autogenerated XML file with VBScript

Status
Not open for further replies.

aptsa

MIS
Jul 18, 2008
1
US
Hi,

I have a program that generates configuration settings in an XML file. However with what little knowledge I have of XML the file does not appear to be formatted correctly. Anyhow the problem is I have to change the server field so the client looks at the new server. I looked at this thread: thread329-1225036 but I am not changing the entire element, just part of it. I tried treating it as text but the file did not save correctly. Anyhow here is the file:


<?xml version="1.0" encoding="UTF-16"?>

<AgentSettings Version="1.0" AgentGuid="60C1E25D-6F3A-4664-9662-F3A2E875FE56" AgentMagicNumber="gvE1z4hx77AwYhMhM7AdDCMcnMJ24NItTtpCfugo67ELHdqPvIMpYuvXNvzWa7sqGfVJcZUQcsIRFB9B/sUbtQ==" AgentPort="18086" PolicyGuid="2415BD00-AF90-4DCB-A5ED-646D3C7D435A" SiteSpecificMagicNumber="UTd2r8pUm46RTQNr2xHQkxEgKOkYqjTnIjlXLaI9uv2KenNWDjyBi8cEkCH0zCQU3rNyV4JgAukLnfbHUGCEsQ==" PolicyServiceFirstAuthenticationFailureTime="1969-12-31T16:00:00" PolicyServiceLastContactTime="2008-07-18T09:17:19" LastKnownGoodPolicyServiceMachineName="Server1" LastKnownGoodPolicyServicePort="18082" LastAgentSoftwareUpdateCheckTime="1601-01-01T00:00:00" LastThreatDbUpdateCheckTime="2008-07-17T13:19:52" NextScheduledQuickScanTime="2008-07-18T19:00:55" NextScheduledDeepScanTime="2008-07-19T19:00:55" LastQuarantineMaintenanceTime="2008-07-17T13:19:52" LastScanHistoryMaintenanceTime="2008-07-17T13:19:52" NeedNewPolicy="false" NeedSoftwareUpdate="false" NeedThreatDbUpdate="false" IsLicenseValid="true"/>


So I want to change Server1 to Server2 with a VBScript.
 
>I tried treating it as text but the file did not save correctly.
I am not sure I understand what it means.

If I follow a bit the referenced thread, it is this.
[tt]
xmlfile="d:\test\input.xml" 'your source file name
outfile="d:\test\output.xml" 'your output file name-maybe the same
set oparser=createobject("msxml2.domdocument")
with oparser
.async=false
.validateOnParse=false
.resolveExternals=false
.load xmlfile
end with

if oparser.parseerror.errorcode<>0 then
wscript.echo "xml file " & xmlfile & " is not well-formed." & vbcrlf & "Operation aborted."
wscript.quit 999
end if

set oroot=oparser.documentElement
oroot.setAttribute "LastKnownGoodPolicyServiceMachineName","server2"
oparser.save outfile

set oparser=nothing[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top