Hello all.
The following lines are an excerpt from a machine.config file:

<configuration>
<system.net>
<connectionManagement>
<add address="*" maxconnection="10"/>
</connectionManagement>
</system.net>

<system.web>
<processModel
enable="true"
timeout="Infinite"
idleTimeout="Infinite"
shutdownTimeout="0:00:05"
requestLimit="Infinite"
requestQueueLimit="5000"
restartQueueLimit="10"
memoryLimit="60"
webGarden="false"
cpuMask="0xffffffff"
userName="machine"
password="AutoGenerate"
logLevel="Errors"
clientConnectedCheck="0:00:05"
comAuthenticationLevel="Connect"
comImpersonationLevel="Impersonate"
responseDeadlockInterval="00:03:00"
maxWorkerThreads="100"
maxIoThreads="100"
minWorkerThreads="50"
/>
</system.web>
</configuration>

I'm using the following VBScript to edit the machine.config file and
change the "maxconnection" value from 10 to 48:

Dim strServer, XMLFilePath, XMLFileName, XMLFile, XMLFileBak
strServer = "000-WEB15-CRS"
XMLFilePath = "\\" & strServer & _
"\C$\Winnt\Microsoft.NET\Framework\v1.1.4322\CONFIG\"
XMLFileName = "machine.config"
XMLFile = XMLFilePath & XMLFileName
XMLFileBak = XMLFileName & "_Backup_" & ".txt"

Set xmlDoc = CreateObject("Msxml.DOMDocument")
xmlDoc.async = False
xmlDoc.PreserveWhitespace = True
xmlDoc.load XMLFile

'~~~ Create backup of original XML file
Set objFSO = CreateObject("Scripting.FileSystemObject")
CreateObject("Scripting.FilesystemObject") _
.GetFile(XMLFile).Name = XMLFileBak

Dim strNode, strKeyName, strNewValue
strNode = "/*/*/*/*[@address=" & Chr(34) & "*" & Chr(34) & "]"
strKeyName = "maxconnection"
strNewValue = "48"

Set objNode = xmlDoc.selectSingleNode (strNode)
objNode.setAttribute strKeyName, strNewValue
xmlDoc.Save XMLFile

Set xmlDoc = nothing
Set objFSO = nothing
Set objNode = nothing

The script works fine, except for one thing. The whitespace appears to
be preserved throughout the machine.config file - except for the
"<processModel" section. This section gets changed - the entire section
ends up on one horizontal line:

<processModel enable="true" timeout="Infinite"
idleTimeout="Infinite" shutdownTimeout="0:00:05"
requestLimit="Infinite" requestQueueLimit="5000" restartQueueLimit="10"
memoryLimit="60" webGarden="false" cpuMask="0xffffffff"
userName="machine" password="AutoGenerate" logLevel="Errors"
clientConnectedCheck="0:00:05" comAuthenticationLevel="Connect"
comImpersonationLevel="Impersonate" responseDeadlockInterval="00:03:00"
maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/>

Any idea what's causing this? Any help would be greatly appreciated.
Thanks!

- Dave

RE: Using XML DOM to update machine.config by ulger

ulger
Wed Dec 13 22:28:02 CST 2006

Only significant whitespace is preserved, that is whitespace as part of
element content. Whitespace between attributes are not significant, so they
are preserved.

--
S. Huseyin Ulger [MSFT]
MSXML Dev


"Highlander" wrote:

> Hello all.
> The following lines are an excerpt from a machine.config file:
>
> <configuration>
> <system.net>
> <connectionManagement>
> <add address="*" maxconnection="10"/>
> </connectionManagement>
> </system.net>
>
> <system.web>
> <processModel
> enable="true"
> timeout="Infinite"
> idleTimeout="Infinite"
> shutdownTimeout="0:00:05"
> requestLimit="Infinite"
> requestQueueLimit="5000"
> restartQueueLimit="10"
> memoryLimit="60"
> webGarden="false"
> cpuMask="0xffffffff"
> userName="machine"
> password="AutoGenerate"
> logLevel="Errors"
> clientConnectedCheck="0:00:05"
> comAuthenticationLevel="Connect"
> comImpersonationLevel="Impersonate"
> responseDeadlockInterval="00:03:00"
> maxWorkerThreads="100"
> maxIoThreads="100"
> minWorkerThreads="50"
> />
> </system.web>
> </configuration>
>
> I'm using the following VBScript to edit the machine.config file and
> change the "maxconnection" value from 10 to 48:
>
> Dim strServer, XMLFilePath, XMLFileName, XMLFile, XMLFileBak
> strServer = "000-WEB15-CRS"
> XMLFilePath = "\\" & strServer & _
> "\C$\Winnt\Microsoft.NET\Framework\v1.1.4322\CONFIG\"
> XMLFileName = "machine.config"
> XMLFile = XMLFilePath & XMLFileName
> XMLFileBak = XMLFileName & "_Backup_" & ".txt"
>
> Set xmlDoc = CreateObject("Msxml.DOMDocument")
> xmlDoc.async = False
> xmlDoc.PreserveWhitespace = True
> xmlDoc.load XMLFile
>
> '~~~ Create backup of original XML file
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> CreateObject("Scripting.FilesystemObject") _
> .GetFile(XMLFile).Name = XMLFileBak
>
> Dim strNode, strKeyName, strNewValue
> strNode = "/*/*/*/*[@address=" & Chr(34) & "*" & Chr(34) & "]"
> strKeyName = "maxconnection"
> strNewValue = "48"
>
> Set objNode = xmlDoc.selectSingleNode (strNode)
> objNode.setAttribute strKeyName, strNewValue
> xmlDoc.Save XMLFile
>
> Set xmlDoc = nothing
> Set objFSO = nothing
> Set objNode = nothing
>
> The script works fine, except for one thing. The whitespace appears to
> be preserved throughout the machine.config file - except for the
> "<processModel" section. This section gets changed - the entire section
> ends up on one horizontal line:
>
> <processModel enable="true" timeout="Infinite"
> idleTimeout="Infinite" shutdownTimeout="0:00:05"
> requestLimit="Infinite" requestQueueLimit="5000" restartQueueLimit="10"
> memoryLimit="60" webGarden="false" cpuMask="0xffffffff"
> userName="machine" password="AutoGenerate" logLevel="Errors"
> clientConnectedCheck="0:00:05" comAuthenticationLevel="Connect"
> comImpersonationLevel="Impersonate" responseDeadlockInterval="00:03:00"
> maxWorkerThreads="100" maxIoThreads="100" minWorkerThreads="50"/>
>
> Any idea what's causing this? Any help would be greatly appreciated.
> Thanks!
>
> - Dave
>
>

Re: Using XML DOM to update machine.config by mr_unreliable

mr_unreliable
Thu Dec 14 11:23:56 CST 2006

Highlander, if you want your generated xml to be tidy,
then you are going to have to tidy it up yourself.

There are a number of "tidy-up-xml" mini-apps out there.
I wrote one myself in about an hour.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)


Highlander wrote:
> Any help would be greatly appreciated.
> Thanks!
>
> - Dave
>

Re: Using XML DOM to update machine.config by Highlander

Highlander
Fri Dec 15 13:32:37 CST 2006


mr_unreliable wrote:
> Highlander, if you want your generated xml to be tidy,
> then you are going to have to tidy it up yourself.
>
> There are a number of "tidy-up-xml" mini-apps out there.
> I wrote one myself in about an hour.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but,
> no guarantee the answers will be applicable to the questions)
>
>
> Highlander wrote:
> > Any help would be greatly appreciated.
> > Thanks!
> >
> > - Dave
> >

jw - Can you post the code for the "tidy-up-xml" mini-app that you
wrote? Or point me in the direction of where I can find the other
mini-apps that are out there? Thanks!

- Dave


Re: Using XML DOM to update machine.config by mr_unreliable

mr_unreliable
Tue Dec 19 11:45:57 CST 2006

--- <snipper> ---
' retrieve the (untidy) xml from the dom...
Dim sXML ' as string
sXML = xmlDoc.xml
' MsgBox(sXML)

' ----------------------------------------------
' tidy up the result...
' ----------------------------------------------
Dim sTidyXML ' as string
' (first step) tidy the result...
sTidyXML = Replace(sXML, ">", ">" & vbCrLf)
' (second step)
sTidyXML = Replace(sTidyXML, "<", " <")
' MsgBox(sTidyXML)
' (third step) remove indent from rootnode tags...
sTidyXML = Replace(sTidyXML, " <?", "<?")
sTidyXML = Replace(sTidyXML, vbCrLf & vbCrLf, vbCrLf)
sTidyXML = Replace(sTidyXML, " <" & sRootNodeName, "<" &
sRootNodeName)
sTidyXML = Replace(sTidyXML, " </" & sRootNodeName, "</" &
sRootNodeName)
MsgBox(sTidyXML)

' sXMLTidySpec = GetLocalDirectory() & sXMLTidyFile ' for debugging
sXMLTidySpec = fso.GetSpecialFolder(tempFolder) & "\" & sXMLTidyFile
' construct the output file...
dbPrint sMe & "save xml tidy file: " & sXMLTidySpec

' write out the tidy file...
Dim oFile, oTextStream ' as object(s)
fso.CreateTextFile sXMLTidySpec, allowOverwrite ' creates the file
(no return)...
Set oXMLOutFile = fso.GetFile(sXMLTidySpec) ' "objectify" the file...

Set oTextStream = oXMLOutFile.OpenAsTextStream(ForWriting) ' ,
TristateUseDefault)
oTextStream.Write sTidyXML
oTextStream.Close

--- <end snippet> ---

Crude but effective, jw

Highlander wrote:
> jw - Can you post the code for the "tidy-up-xml" mini-app that you
> wrote? Or point me in the direction of where I can find the other
> mini-apps that are out there? Thanks!
>
> - Dave
>