TinyXML解析 void writeSchoolXml() { using namespace std; const char * xmlFile = “conf/school-write.xml”; TiXmlDocument doc; TiXmlDeclaration * decl = new TiXmlDeclaration(“1.0”, “”, “”); TiXmlElement * schoolElement = new TiXmlElement( “School” ); TiXmlElement * classElement = new TiXmlElement( “Class” ); classElement->SetAttribute(“name”, “C++”); TiXmlElement * stu1Element = new TiXmlElement(“Student”); stu1Element->SetAttribute(“name”, “tinyxml”); stu1Element->SetAttribute(“number”, “123”); TiXmlElement * stu1EmailElement = new TiXmlElement(“email”); stu1EmailElement->LinkEndChild(new TiXmlText(“tinyxml@163.com”) ); TiXmlElement * stu1AddressElement = new TiXmlElement(“address”); stu1AddressElement->LinkEndChild(new TiXmlText(“中国”)); stu1Element->LinkEndChild(stu1EmailElement); stu1Element->LinkEndChild(stu1AddressElement); TiXmlElement * stu2Element = new TiXmlElement(“Student”); stu2Element->SetAttribute(“name”, “jsoncpp”); stu2Element->SetAttribute(“number”, “456”); TiXmlElement * stu2EmailElement = new TiXmlElement(“email”); stu2EmailElement->LinkEndChild(new TiXmlText(“jsoncpp@163.com”)); TiXmlElement * stu2AddressElement = new TiXmlElement(“address”); stu2AddressElement->LinkEndChild(new TiXmlText(“美国”)); stu2Element->LinkEndChild(stu2EmailElement); stu2Element->LinkEndChild(stu2AddressElement); classElement->LinkEndChild(stu1Element); classElement->LinkEndChild(stu2Element); schoolElement->LinkEndChild(classElement); doc.LinkEndChild(decl); doc.LinkEndChild(schoolElement); doc.SaveFile(xmlFile); }
2024最新激活全家桶教程,稳定运行到2099年,请移步至置顶文章:https://sigusoft.com/99576.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。 文章由激活谷谷主-小谷整理,转载请注明出处:https://sigusoft.com/26177.html