1.tinyXMl生成XML文件
#include <stdio.h>
#include <string>
using namespace std;
#include "../tinyxml/tinyxml.h"
int test1()
{
TiXmlDocument xml_doc;
// 添加XML声明
xml_doc.LinkEndChild(new TiXmlDeclaration( "1.0", "GBK", "" ));
// 添加根元素
TiXmlElement * xml_root = new TiXmlElement("root");
xml_doc.LinkEndChild(xml_root);
// 在根元素下添加其他子元素
if(1)
{
// 添加host
TiXmlElement* xml_child = new TiXmlElement("host");
xml_root->LinkEndChild(xml_child );
// 添加文档内容
xml_child->LinkEndChild( new TiXmlText("AAA"));
// 设置属性
xml_child->SetAttribute("checked", "true");
xml_child->SetAttribute("station", 1001);
}
if(1)