墨香年少 32 发布于 2021年4月18日 #include <iostream> #include "Markup.h" using namespace std; int main() { CMarkup xml; xml.Load("D:\\PROJECTS\\TestXML\\Debug\\MyTest.xml"); BOOL findEle = xml.FindElem(); if (!findEle) { cerr << "can not find element!"; return 1; } xml.IntoElem(); //<Person name="duqingnian" age="36" address="江苏省" /> BOOL b = xml.FindElem("Person"); if (!b) { cout << "lost Person !!!" << endl; } cout << "name=" << xml.GetAttrib("name") << ", age=" << xml.GetAttrib("age") << ",addres=" << xml.GetAttrib("address") << endl;; if (true) { BOOL p = xml.FindElem("Phone"); if (!p) { cout << "lost phone!!" << endl; } xml.IntoElem(); xml.FindElem("Disk"); cout << xml.GetAttrib("size") << endl; } xml.OutOfElem(); //<Hello ID="HID">nihao</Hello> if (true) { BOOL a = xml.FindElem("Hello"); if (!a) { cout << "lost Hello!!" << endl; } cout << "data=" << xml.GetData() << ",id=" << xml.GetAttrib("ID") << endl; } cout << "over" << endl; return 0; } //XML /** <?xml version="1.0" encoding="UTF-8"?> <Window> <Person name="duqingnian" age="36" address="江苏省" /> <Phone> <Cpu stype="intel" /> <Memory size="16GB" /> <Disk size="512GB" type="固态" /> </Phone> <Hello ID="HID">nihao</Hello> </Window> */ //OUTPUT: /** name=duqingnian, age=36,addres=江苏省 512GB data=nihao,id=HID over */ CMarkup 目之所及,皆是回忆,心之所想,皆是过往 分享这篇帖子 链接帖子 分享到其他站点