温馨提示×

tinyxml第一课 生成xml文件

发布时间:2020-07-30 20:32:32 来源:网络 阅读:874 作者:fengyuzaitu 栏目:编程语言

    tinyxml是一个C++跨平台开源库,XML文件切记不要使用Windows记事本打开编辑,最好使用Notepad++进行编辑打开


生成文本:

<?xml version="1.0" encoding="UTF-8" ?>
<MyGUI type="Resource" version="1.1" />


生成代码

 TiXmlElement *RootElement = NULL;
 TiXmlDocument *pDoc = NULL;
 pDoc = new TiXmlDocument();
 TiXmlDeclaration *pDeclaration = new TiXmlDeclaration(("1.0"), ("UTF-8"), (""));
 pDoc->LinkEndChild(pDeclaration);
 RootElement = new TiXmlElement(("MyGUI"));
 RootElement->SetAttribute("type", "Resource");
 RootElement->SetAttribute("version", "1.1");
 pDoc->LinkEndChild(RootElement);
 pDoc->SaveFile("fengyuzaitu51cto.xml");
 delete pDoc;


注意:

        tinyxml:Could not load test file Error='Error reading Attributes.'. Exiting.描述:使用windows写字板编辑任何的xml文件,保存成为纯文本文件导致的问题,是下面属性完全消失
Could not load test file 'test.xml'.Error='Error reading Attributes.'. Exiting.

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。