#include "tinyxml.h"
#include "tinystr.h"
#include <iostream>
using namespace std;
int main(){
cout<<"begin"<<endl;
TiXmlDocument *myDocument = new TiXmlDocument();
myDocument->LoadFile("student.xml");
myDocument->Print();
TiXmlElement *rootElement = myDocument->RootElement();
cout<<rootElement->Value()<<endl;
TiXmlElement *firstElement = rootElement->FirstChildElement();
TiXmlElement *studentElement = firstElement->FirstChildElement();
cout<<studentElement->Value()<<endl;
cout<<studentElement->Attribute("name")<<endl;
cout<<studentElement->Attribute("studentNo")<<endl;
cout<<studentElement->Attribute("sex")<<endl;
cout<<studentElement->Attribute("age")<<endl;
TiXmlElement *phoneElement = studentElement->FirstChildElement();
cout<<phoneElement->Value()<<endl;
cout<<phoneElement->GetText()<<endl;
TiXmlElement *studentElement2 = studentElement->NextSiblingElement();
cout<<studentElement2->Attribute("name")<<endl;
return 0;
}
tinyxml
最新推荐文章于 2020-07-22 09:32:17 发布