XML的声明

titicacahang titicacahang 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
通过createProcessingInstruction()
代码如下:
pDoc->insertBefore((MSXML2::IXMLDOMNode*)pDoc->createProcessingInstruction("xml","version=\"1.0\"encoding=\"UTF-8"),
_variant_t((LPDISPATCH)xmlRoot.GetInterfacePtr()));
pDoc->save("d:\\he.xml");
然后打开he.xml,可以看到是有<?xml version="1.0" encoding="UTF-8" ?>

但是如果我是想不通过pDoc->save("d:\\he.xml"); (想节约处理时间)
而是直接通过CString strTT;
strTT.Empty();
strTT.Format("%s", (LPCSTR)pDoc->xml);
这样打印出来的strTT是<?xml version="1.0" ?>
而encoding="UTF-8"这一行却不见了??
这个应该怎么处理,?? 难道只能是自己通过手动添加<?xml version="1.0" encoding="UTF-8" ?>这一行吗?
...全文
评论 8
收藏 已收藏
分享
返回顶部
titicacahang
VC/MFC 16,550 成员 421,606 内容