gpt4 book ai didi

vb6 - 如何使用 VB6 和 MSXML 漂亮地打印 XML 源代码?

转载 作者:行者123 更新时间:2023-12-02 19:41:12 31 4
gpt4 key购买 nike

我已经关注这个问题好几个月了,我发现大多数网站都在问同样的问题。

找到的答案总是针对.NET或C++或涉及XSLT。

最佳答案

经过几个月的研究,我想出了这个。

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 - 如何使用 VB6 和 MSXML 漂亮地打印 XML 源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1118576/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com