' Version Date: 30.09.2020 ' Source: https://stackoverflow.com/questions/25067839/format-xml-string-in-vbscript Function prettyXml(ByVal sDirty) ' Put whitespace between tags. (Required for XSL transformation.) sDirty = Replace(sDirty, "><", ">" & vbCrLf & "<") ' Create an XSL stylesheet for transformation. Dim objXSL : Set objXSL = WScript.CreateObject("Msxml2.DOMDocument") objXSL.loadXML "" & _ "" & _ "" & _ "" & _ "" & _ "" ' Transform the XML. Dim objXML : Set objXML = WScript.CreateObject("Msxml2.DOMDocument") objXML.loadXml sDirty objXML.transformNode objXSL prettyXml = objXML.xml End Function