Microsoft.XMLDOM xml串 encoding

本文解释了Microsoft.XMLDOM中xml属性返回的XML字符串没有encoding属性的原因,仅在使用save方法时才会保留原始编码格式。

根据微软的说明,Microsoft.XMLDOM xml属性取出的XML串是没有encoding属性的,只有save方法才有。参见微软的MSDN说明:

http://msdn.microsoft.com/en-us/library/ms755989(v=VS.85).aspx

The property is read-only.

The xml property always returns a Unicode string. That is, the xml property for DOMDocument converts the document from its original encoding to Unicode. As a result, the original encoding attribute is removed. For example, <?xml version="1.0" encoding="UTF-8"?> appears in the xml property as follows.

other
<?xml version="1.0"?>

If the original encoding was not removed by the xml property, the following line returns an error indicating the parser cannot switch from Unicode to UTF-8 encoding.

other
xmlDoc.loadxml(xmlDoc.xml);

If you use the save method, the original encoding is preserved. For example, if you load a document in Microsoft® Windows® 1252 encoding, it will be saved in that format.

This value depends on the value of the nodeType property.


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值