一、写xml 文件
- #include<iostream>
- #include"rapidxml/rapidxml.hpp"
- #include"rapidxml/rapidxml_utils.hpp" @H_403_38@ #include"rapidxml/rapidxml_print.hpp"
- @H_403_38@ usingnamespacerapidxml;
- intmain()
- { @H_403_38@ xml_document<>doc;
- xml_node<>*rot=doc.allocate_node(rapidxml::node_pi,doc.allocate_string("xmlversion='1.0'encoding='utf-8'")); @H_403_38@ doc.append_node(rot);
- xml_node<>*node=doc.allocate_node(node_element,"config","information"); @H_403_38@ xml_node<>*color=doc.allocate_node(node_element,"color",NULL);
- doc.append_node(node); @H_403_38@ node->append_node(color);
- color->append_node(doc.allocate_node(node_element,"red","0.1")); @H_403_38@ color->append_node(doc.allocate_node(node_element,"green","0.1"));
- "blue","alpha","1.0"));
- xml_node<>*size=doc.allocate_node(node_element,"size",108); list-style:decimal-leading-zero outside; color:inherit; line-height:18px; margin:0px!important; padding:0px 3px 0px 10px!important"> size->append_node(doc.allocate_node(node_element,"x","640")); @H_403_38@ size->append_node(doc.allocate_node(node_element,"y","480"));
- node->append_node(size); @H_403_38@
- xml_node<>*mode=doc.allocate_node(rapidxml::node_element,"mode","screenmode"); @H_403_38@ mode->append_attribute(doc.allocate_attribute("fullscreen","false"));
- node->append_node(mode);
- std::stringtext; @H_403_38@ rapidxml::print(std::back_inserter(text),doc,0);
- std::cout<<text<<std::endl;
- std::ofstreamout("config.xml");
- out<<doc;
- system("PAUSE");
- returnEXIT_SUCCESS;
- }
生成的xml如下