【问题标题】:MSXML2.DomDocument.3.0 invalid charactersMSXML2.DomDocument.3.0 无效字符
【发布时间】:2009-06-18 22:39:34
【问题描述】:

在将 XML 解析为来自 Web 服务的答案时,我收到以下错误。

  • 在文本内容中发现无效字符。

Web 服务会发送带有某些字符的答案,例如 Ψ 或带有 " 或 字符的 HTML 结构化测试。

使用的代码是:

Set var_xmlPostObject = CreateObject("MSXML2.ServerXMLHTTP.3.0")
Set var_xmlRequestDoc = CreateObject("MSXML2.DOMDocument")
Set var_xmlResponseDoc = CreateObject("MSXML2.DomDocument.3.0")
'Send xml
Call var_xmlRequestDoc.loadXML(str_xml)
Dim var_pi As Variant
Set var_pi = var_xmlRequestDoc.CreateProcessingInstruction("xml", "version='1.0' encoding='ISO-8859-1'")
Call var_xmlRequestDoc.InsertBefore(var_pi, var_xmlRequestDoc.ChildNodes(0)) 'open the POST (or GET) connection to the web server
Call var_xmlPostObject.open("POST", str_soapPost, False)
Call var_xmlPostObject.setRequestHeader("Content-Type", str_soapType)
Call var_xmlPostObject.send(var_xmlRequestDoc.xml)
'Set response properties
var_xmlResponseDoc.async = False
var_xmlResponseDoc.validateOnParse = False
var_xmlResponseDoc.resolveExternals = False
Set var_xmlResponseDoc = var_xmlPostObject.responseXML
Print "var_xmlResponseDoc.xml: " & var_xmlResponseDoc.xml
If var_xmlResponseDoc.parseError.errorCode <> 0 Then
    'Alert
Else
    'Do something
End if

问题是是否有一种方法可以在解析之前检测带来消息的字符?举个例子就好了。

提前致谢。

【问题讨论】:

    标签: xml parsing lotusscript


    【解决方案1】:

    您可能想采用不同的方法。 Notes 8 允许您在本地使用 Web 服务并只处理一些 LotusScript(或 Java 类)。核心代码将负责编码等,因此您无需处理它。如果出于政治原因您卡在过时版本的 Lotus Notes 上,您可以使用 [Stubby][1](Web 服务杀手)来生成代码。比 OLE 连接可靠得多。

    [1]:http://www.nsftools.com/stubby/Stubby

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-16
      • 1970-01-01
      • 2019-05-02
      • 2017-01-01
      • 2021-12-14
      相关资源
      最近更新 更多