为什么createProcessingInstruction在MSXML产生不完整的输出? [英] Why does createProcessingInstruction in MSXML generate incomplete output?

查看:542
本文介绍了为什么createProcessingInstruction在MSXML产生不完整的输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的VBA code生成< XML版本=1.0> 作为输出

The following VBA code generates <?xml version="1.0"?> as output.

Dim XML As New DomDocument 
Dim pi As IXMLDOMProcessingInstruction

'.... some code that sets the root element of the document

Set pi = XML.createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'")
        XML.insertBefore pi, XML.documentElement

为什么编码=UTF-8冷落?

推荐答案

UTF-8的默认编码反正。你指定什么是多余的,所以序列化可能忽略了它。该版本字段不是可选字段,但。如果文件中有一个XML声明可言,的声明必须包含版本字段

UTF-8 is the default encoding anyway. What you've specified is redundant, so the serializer likely omits it. The version field is not an optional field, though. If the file has an XML declaration at all, the declaration must include the version field.

这篇关于为什么createProcessingInstruction在MSXML产生不完整的输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆