如何使用 VB6 和 MSXML 漂亮地打印 XML 源? [英] How can I pretty-print XML source using VB6 and MSXML?
本文介绍了如何使用 VB6 和 MSXML 漂亮地打印 XML 源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我几个月来一直在关注这个问题,我发现大多数网站都在问同样的问题.
I've been looking after this for months now and I mostly found sites asking the same question.
我找到的答案总是针对 .NET 或 C++ 或涉及 XSLT.
The answers I did found were always for .NET or C++ or involved XSLT.
推荐答案
经过几个月的研究,我想出了这个.
After months of research I've come up with this.
Public Function PrettyPrintXML(XML As String) As String
Dim Reader As New SAXXMLReader60
Dim Writer As New MXXMLWriter60
Writer.indent = True
Writer.standalone = False
Writer.omitXMLDeclaration = False
Writer.encoding = "utf-8"
Set Reader.contentHandler = Writer
Set Reader.dtdHandler = Writer
Set Reader.errorHandler = Writer
Call Reader.putProperty("http://xml.org/sax/properties/declaration-handler", _
Writer)
Call Reader.putProperty("http://xml.org/sax/properties/lexical-handler", _
Writer)
Call Reader.parse(XML)
PrettyPrintXML = Writer.output
End Function
使用文档:
Public Function PrettyPrintDocument(Doc As DOMDocument60) As String
PrettyPrintDocument = PrettyPrintXML(Doc.XML)
End Function
这篇关于如何使用 VB6 和 MSXML 漂亮地打印 XML 源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文