Skip to content

Commit

Permalink
删除原始方法
Browse files Browse the repository at this point in the history
  • Loading branch information
woodyxiong authored Oct 8, 2017
1 parent 7a7ab92 commit 8dfd3b3
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"<<endl;
XMLElement *root=doc->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;
Expand All @@ -60,4 +33,4 @@ void parseSimple(){
}catch (string e){
cout<<e<<endl;
}
}
}

0 comments on commit 8dfd3b3

Please sign in to comment.