问hookee大俠(刚结的贴,又有个问题!)

pumnfood 2009-08-30 10:20:50
你的这个过程,我刚刚发现个问题
encoding编码怎么改不掉啊,总是UTF-16


formatDoc xml, server.mappath("xml.xml")

Sub formatDoc(ByRef oDoc, sFilename)
On Error Resume Next
Dim oSAXWriter, oSAXReader

Set oSAXWriter = CreateObject("Msxml2.MXXMLWriter.6.0")
Set oSAXReader = CreateObject("Msxml2.SAXXMLReader.6.0")
With oSAXWriter
.encoding = "UTF-8"
.byteOrderMark = True
.standalone = True
.omitXMLDeclaration = False
.indent = True
End With
With oSAXReader
Set .contentHandler = oSAXWriter
Set .dtdHandler = oSAXWriter
Set .errorHandler = oSAXWriter
.putProperty "http://xml.org/sax/properties/lexical-handler", oSAXWriter
.putProperty "http://xml.org/sax/properties/declaration-handler", oSAXWriter
.parse oDoc
End With
With oDoc
.loadXML oSAXWriter.output
If .parseError.errorCode <> 0 Then
sErrMsg = .parseError.errorCode & "|" &_
.parseError.srcText & "|" & .parseError.reason
On Error GoTo 0
Err.Raise 30000, "formatDoc", sErrMsg
Exit Sub
End If
.save sFilename
End With
Set oSAXWriter = Nothing
Set oSAXReader = Nothing
End Sub
...全文
22 点赞 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2009-08-30
.encoding = "GB2312" 的话可以得到 UTF-8
或者Replace掉
s = oSAXWriter.output
s = Replace(s,"encoding=""UTF-16""", "")
oDoc.loadXML s

回复
发动态
发帖子
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
社区公告
暂无公告