//————————————————–生成XML————
/*tinyxml2::XMLDocument *pDOC = new tinyxml2::XMLDocument();
XMLDeclaration *pDec = pDOC->NewDeclaration(“xml version=\”1.0\”encoding=\”UTF-8\”“);
pDOC->LinkEndChild(pDec);
XMLElement *p1 = pDOC->NewElement(“PC”);
pDOC->LinkEndChild(p1);
XMLElement *p11 = pDOC->NewElement("PC1");
XMLElement *p12 = pDOC->NewElement("PC2");
XMLElement *p13 = pDOC->NewElement("PC3");
p11->LinkEndChild(pDOC->NewText("nihao"));
p12->LinkEndChild(pDOC->NewText("nihao"));
p13->LinkEndChild(pDOC->NewText("nihao"));
p1->LinkEndChild(p11);
p1->LinkEndChild(p12);
p1->LinkEndChild(p13);
std::string filep = FileUtils::getInstance()->getWritablePath() + "nihao.xml";
log("-----------------------------");
log("%s",filep.c_str());
log("-----------------------------");
pDOC->SaveFile(filep.c_str());
delete pDOC;*/
//--------------------------------------------------生成XML------------
//--------------------------------------------------解析XML------------
/* std::string filep=FileUtils::getInstance()->getWritablePath()+ "nihao.xml";
tinyxml2:: XMLDocument *pDoc = new tinyxml2::XMLDocument();
XMLError errorid = pDoc->LoadFile(filep.c_str());
if (errorid!=0) {
}
XMLElement *rootelm = pDoc->RootElement();
const XMLAttribute *attrib = rootelm->FirstAttribute();
log("Attribute_name=%s Attribute_value=%s ",attrib->Name(),attrib->Value());
XMLElement *a1 = rootelm->FirstChildElement("PC1");*/
/* XMLElement *a2 = a1->NextSiblingElement("PC2");
XMLElement *a3 = a2->NextSiblingElement("PC3");
log("PC1.text is %s ;PC2.text is %s;PC3.text is %s ", a1->GetText(), a2->GetText(), a3->GetText());*/
/* while (a1) {
log("text is %s", a1->GetText());
XMLElement *anext = a1->NextSiblingElement();
a1 = anext;
}
delete pDoc;*/
//--------------------------------------------------解析XML------------
//--------------------------------------------------生成JSON------------
std::string filp = FileUtils::getInstance()->getWritablePath() + "test.json";
log("%s", filp.c_str());
rapidjson::Document document;
document.SetObject();
rapidjson::Document::AllocatorType& allocator = document.GetAllocator();
rapidjson::Value array(rapidjson::kArrayType);
rapidjson::Value object(rapidjson::kObjectType);
object.AddMember("int",1,allocator);
object.AddMember("name", "wang", allocator);
array.PushBack(object,allocator);
document.AddMember("json","json string",allocator);
document.AddMember("array", array, allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> write(buffer);
document.Accept(write);
FileUtils::getInstance()->writeStringToFile(buffer.GetString(), filp);
//--------------------------------------------------生成JSON------------