32 lines
1.5 KiB
Plaintext
32 lines
1.5 KiB
Plaintext
' prettyXml(sDirty : String)
|
|
' ----------------------------------------------------------------------------
|
|
' Source: https://stackoverflow.com/questions/25067839/format-xml-string-in-vbscript
|
|
'
|
|
' Returns: prettyXml : String
|
|
' ----------------------------------------------------------------------------
|
|
' Copyright (c) 2021 by Digital Data GmbH
|
|
'
|
|
' Digital Data GmbH • Ludwig-Rinn-Strasse 16 • D-35452 Heuchelheim
|
|
' Tel.: 0641/202360 • E-Mail: info-flow(at)digitaldata.works
|
|
' ----------------------------------------------------------------------------
|
|
' Creation Date / Author: 30.09.2020 / XX
|
|
' Version Date / Editor: 30.09.2020 / XX
|
|
' Version Number: 1.0.0.0
|
|
|
|
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 "<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">" & _
|
|
"<xsl:output method=""xml"" indent=""yes""/>" & _
|
|
"<xsl:template match=""/"">" & _
|
|
"<xsl:copy-of select="".""/>" & _
|
|
"</xsl:template>" & _
|
|
"</xsl:stylesheet>"
|
|
' Transform the XML.
|
|
Dim objXML : Set objXML = WScript.CreateObject("Msxml2.DOMDocument")
|
|
objXML.loadXml sDirty
|
|
objXML.transformNode objXSL
|
|
prettyXml = objXML.xml
|
|
End Function |