生成XML示例代码:
#include "XMLMake.h"XMLMake xm; IXMLNode* pRootNode = xm.AddNode(0, _T("library")); IXMLNode* pBookNode = xm.AddNode(pRootNode, _T("book")); xm.SetAttributeValue(pBookNode, _T("date"), _T("2003-10-03")); xm.SetAttributeValue(pBookNode, _T("pages"), _T("800")); xm.AddElementValue(pBookNode, _T("书名"), _T("C++程序设计语言(特别版)")); IXMLNode* pN = xm.AddNode(pBookNode, _T("bb")); xm.SetNodeValue(pN, _T("Hello!")); xm.SetAttributeValue(pN, _T("age"), _T("99")); xm.ReleaseNode(&pN); xm.ReleaseNode(&pBookNode); xm.ReleaseNode(&pRootNode); xm.Save(_T("C:\\test.xml"));
生成的XML文件内容如下: <?xml version="1.0" encoding="UTF-16"?> <library> <book date="2003-10-03" pages="800"> <书名>C++程序设计语言(特别版)</书名> <bb age="99">Hello!</bb> </book> </library>
内附源码及示例代码(包括XMLParse解析源码)
http://www.nhvideo.net/codes/XML_Wrapper.rar