Kategorien
CodeArchiv VBA XML

VBA XML Beautiful

Beschreibung

Erstellt aus einem XML Objekt eine schön lesbaren Text!

Code

Function XmlBeautiful(ByVal xmldoc, Optional ByVal EmitXMLDeclaration As Boolean) As String
    Dim objReader As SAXXMLReader60
    Set objReader = New SAXXMLReader60
    
    Dim objWriter As MXXMLWriter60
    Set objWriter = New MXXMLWriter60
    
    objWriter.Indent = True
    objWriter.omitXMLDeclaration = Not EmitXMLDeclaration
    Set objReader.contentHandler = objWriter
    objReader.parse (xmldoc)
    XmlBeautiful = objWriter.output
End Function

Download