title: Write XML string directly to XML file with VBScript
body: <p>My OS is Windows&nbsp;7 64Bit. I need to write the following XML string along with interpreted dynamic content to an XML file (also maintaining the tabs indentation) by using VBScript:</p>
  
  <p>File Name: <code>[Variable1]_[Variable2].xml</code></p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0"?&gt;
  &lt;config&gt;
      &lt;modules&gt;
          &lt;[Variable1]_[Variable2]&gt;
              &lt;active&gt;true&lt;/active&gt;
              &lt;codePool&gt;[Variable3]&lt;/codePool&gt;
              &lt;version&gt;[Variable4]&lt;/version&gt;
          &lt;/[Variable1]_[Variable2]&gt;
      &lt;/modules&gt;
  &lt;/config&gt;
  </code></pre>
  
  <p>All I could try for that is below script to create various tags and elements one-by-one.</p>
  
  <pre class="lang-vb prettyprint-override"><code>scriptDir = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
  Set xmlDoc = CreateObject("Msxml2.DOMDocument.3.0")
  Set objRoot = xmlDoc.CreateElement("config")
  xmlDoc.AppendChild objRoot
  Set objRecord = xmlDoc.CreateElement("modules")
  objRoot.AppendChild objRecord
  Set objName = xmlDoc.CreateElement("Mageweb_ShippingFilter")
  objName.Text = ""
  objRecord.AppendChild objName
  Set objDate = xmlDoc.CreateElement("AuditDate")
  objDate.Text = Date
  objRecord.AppendChild objDate
  Set objIntro = xmlDoc.CreateProcessingInstruction("xml", "version='1.0'")
  xmlDoc.InsertBefore objIntro, xmlDoc.ChildNodes(0)
  'For now there is static name of file
  xmlDoc.Save scriptDir &amp; "\Testfile.xml"
  </code></pre>
  
  <p>But this seems to be too cumbersome for possibly large XML files in future, so can I just write the above XML string (with all variables interpreted with their relevant values) I mentioned, directly to XML file and then give a variable-based dynamic name with VBScript?</p>