UNICODE模式下使用rapidxml写XML文件

来源:互联网 发布:编程范式有什么好处 编辑:程序博客网 时间:2024/05/21 21:41

2014年3月28日16:06:31

UNICODE模式下使用rapidxml写XML文件

1、使用VS2008创建一个带预编译头的控制台项目。

2、源文件内容:

#include "stdafx.h" #include<iostream>  using namespace std;#include "rapidxml.hpp"#include "rapidxml_utils.hpp"#include "rapidxml_print.hpp"using namespace rapidxml;int main(){    xml_document<TCHAR> doc;  xml_node<TCHAR>* rot = doc.allocate_node(node_pi,doc.allocate_string(_T("xml version='1.0' encoding='GB2312'")));doc.append_node(rot);doc.append_node(doc.allocate_node(node_comment,NULL,_T("中心传输配置")));xml_node<TCHAR>* node =   doc.allocate_node(node_element,_T("CenterTransConfig"),NULL);doc.append_node(node);node->append_node(doc.allocate_node(node_comment,NULL,_T("进程定点自杀小时")));xml_node<TCHAR>* color =   doc.allocate_node(node_element,_T("kill_hour"),_T("23"));  node->append_node(color);node->append_node(doc.allocate_node(node_comment,NULL,_T("日志系统等级")));xml_node<TCHAR>* size =   doc.allocate_node(node_element,_T("log_level"),_T("0"));node->append_node(size);#ifdef UNICODEwofstream out(_T("CenterTransConfig.xml"));out.imbue(locale("CHS"));#elseofstream out(_T("CenterTransConfig.xml"));#endifout << doc;system("PAUSE");return EXIT_SUCCESS;}


2、编译报错。修改rapdidxml[rapidxml_print.hpp 403行]

 //print(std::ostream_iterator<Ch>(out), node, flags);print(std::ostream_iterator<Ch,Ch>(out), node, flags);




0 0
原创粉丝点击