Here's another useful bit of code used to generate formatted XML. This particular code - in C++ form - will eventually be incorporated into the Platypus API Service, when logging API calls is enabled.
Function PrettyPrintXML(strXML)
Dim objReader, objWriter
Set objReader = CreateObject("MSXML2.SAXXMLReader.6.0")
Set objWriter = CreateObject("MSXML2.MXXMLWriter.6.0")
objWriter.indent = True
objWriter.standalone = False
objWriter.omitXMLDeclaration = False
objWriter.encoding = "utf-8"
Set objReader.contentHandler = objWriter
Set objReader.dtdHandler = objWriter
Set objReader.errorHandler = objWriter
objReader.putProperty _
"http://xml.org/sax/properties/declaration-handler", _
objWriter
objReader.putProperty _
"http://xml.org/sax/properties/lexical-handler", _
objWriter
objReader.parse strXML
PrettyPrintXML = objWriter.output
End Function
The credit for this actually goes to Daniel Rikowski on StackOverflow. All I did was convert it into usable VBScript.
No comments:
Post a Comment