Created
February 13, 2014 14:57
-
-
Save atifaziz/8976460 to your computer and use it in GitHub Desktop.
XML pretty printing in VBA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function PrettyXML(ByVal Source, Optional ByVal EmitXMLDeclaration As Boolean) As String | |
Dim Writer As MXXMLWriter, Reader As SAXXMLReader | |
Set Writer = New MXXMLWriter | |
Writer.indent = True | |
Writer.omitXMLDeclaration = Not EmitXMLDeclaration | |
Set Reader = New SAXXMLReader | |
Set Reader.contentHandler = Writer | |
Reader.Parse Source | |
PrettyXML = Writer.Output | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: If you are using MSXML 6.0, you need to qualify the declarations with a 6.0 on the end.
This worked well for me in Access VBA.