今天下午写了个自动生成xml文件的demo.代码如下:
#include <fstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
class XmlElement
{
public:
XmlElement();
void SetElementName(string& name);
void SetAttribute(const string& attributeName,const string& attributeValue);
void AddSubElement(const XmlElement* InElement);
void SetTextNode(string& InValue);
friend ofstream& operator << (ofstream& out,const XmlElement& InElem)
{
out.open("E:\\myXmlDemo.xml");
out << "<" << "?xml version=\"1.0\" encoding=\"UTF-8\"?" << ">" << endl;
InElem.WriteToXmlFile(out);
out.close();
return out;
}
void WriteToXmlFile(ofstream& outFile,int IndentLevel = 0) const;
void IndentXmlFile(ofstream&