From 8dfd3b30c08da85171eba70a22371382f84bc34c Mon Sep 17 00:00:00 2001 From: Woody Xiong Date: Sun, 8 Oct 2017 14:59:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=9F=E5=A7=8B=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/main.cpp b/main.cpp index 7ba5c3a..3e1d999 100644 --- a/main.cpp +++ b/main.cpp @@ -4,38 +4,11 @@ using namespace std; using namespace tinyxml2; const char* xmlpath="example.xml"; const char* xmlpathError="errorExample.xml"; -void parseTinyXML(); void parseSimple(); int main(){ -// parseTinyXML(); parseSimple(); - return 0; } - -void parseTinyXML(){ - XMLDocument* doc=new XMLDocument; - int status=doc->LoadFile(xmlpathError); - if(status!=0) - cout<<"open failed"<RootElement(); - XMLElement *user=root->FirstChildElement("user"); - while(user){ - string elename=user->GetText(); - if(elename.compare("user0")==0){ - XMLElement *email=user->FirstChildElement("email"); - while(email){ - XMLElement *dizhi=doc->NewElement("dizhi"); - email->InsertEndChild(dizhi); - email=email->NextSiblingElement(); - } - break; - } - user=user->NextSiblingElement(); - } - doc->SaveFile(xmlpathError); -} - void parseSimple(){ try { Simplexml* simplexml; @@ -60,4 +33,4 @@ void parseSimple(){ }catch (string e){ cout<