将数据写入一个XML文件

bool SaveXMLConfig(const char* szFileName)
{
	TiXmlDocument doc;
	TiXmlDeclaration *pDeclaration = new TiXmlDeclaration("1.0", "utf-8", "");
	doc.LinkEndChild(pDeclaration);

	TiXmlElement *pRootElm = new TiXmlElement("Ui");
	doc.LinkEndChild(pRootElm);

	TiXmlElement *pPanelElm = new TiXmlElement("Panel");
	pPanelElm->SetAttribute("type", "Panel");
	pXmlElement->SetAttribute("name", "TestPanel");
	pRootElm->LinkEndChild(pPanelElm);

	doc.SaveFile(szFileName);

	return true;
}

你可能感兴趣的:(C++)