XML文件解析器TXml(2)
2015-08-26来源:易贤网

#include "XmlDocument.h"

int main()

{

{

XmlDocument doc;

doc.Load("test.txt");

cout<<"XML头部:"<<doc.Head().c_str()<<endl;

cout<<"显示全部学生成绩:" ;

doc.ShowXML(doc);

cout<<endl;

vector<XmlNode*> vect;

doc.SelectNodes("students/student/courses/course",vect);

XmlNode* node=doc.SelectSingleNode("students/Student/courses/course/Course");

if(node!=NULL)

{

node->ShowXML(*node);

cout<<"name:"<<node->Name().c_str()<<endl;

cout<<"属性:";

node->ShowAttr() ;

cout<<endl;

cout<<"value:"<<node->Value().c_str()<<endl;

cout<<"ChildCount:"<<node->ChildCount()<<endl<<endl;

XmlNode::Iterator iter=node->begin();

while(iter!=node->end())

{

cout<<"name:"<<(*((iter)._Ptr))->Name().c_str() <<endl;

cout<<"value:"<<(*((iter)._Ptr))->Value().c_str() <<endl;

iter++;

}

}

cout<<"查找name=‘英文’的节点:"<<endl;

XmlNode* node2=doc.SelectSingleNodeByAttr("name","英文");

if(node2!=NULL){

node2->ShowXML(*node2);

}

}

system("pause");

return 0;

}

名单

更多信息请查看IT技术专栏

推荐信息