#include <iostream>
#include <string>
using namespace std;
#include "tinyxml.h"
void parseXml(TiXmlNode* node) { for (TiXmlElement* nodeEle = node->FirstChildElement(); nodeEle != nullptr; nodeEle = nodeEle->NextSiblingElement()) { TiXmlNode* tempEle = nodeEle; if (nodeEle->GetText() != NULL) { string tag = nodeEle->Value(); string content = nodeEle->GetText(); cout << "tag:" << tag << endl; cout << "\t\t" << "content:" << content << endl; } if (!tempEle->NoChildren()) { parseXml(tempEle); } }}
int main()
{ string strfile; cout << "input xml file name:"; cin >> strfile; TiXmlDocument doc(strfile.c_str()); if (doc.LoadFile()) { parseXml(doc.RootElement()); } else cout << "no xml found!!!" << endl; }
就是將tag和content保存到文本里面,這個該怎么寫代碼呀?
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/282179.html
標籤:新手樂園
