MSXML类封装
来源:互联网 发布:印刷自动报价软件 编辑:程序博客网 时间:2024/05/16 10:23
目的:为了更方便的读写XML文档,对MSXML4.0类进行封装
主要解决一些接口参数转换问题
使用前确保已经安装好MSXML4.0且设置好环境
适合VC开发语言
下面是类:
class WLWXML
{
public:
WLWXML()
{
m_pIXMLDoc = NULL;
}
~WLWXML()
{
SafeReleaseXMLDoc();
}
// 创建一个XML文档,成功返回true,失败返回false
bool ConstructXMLFile();
// 从文件加载一个XML文件,加载成功返回true,加载失败返回false
bool LoadFromXMLFile(const std::string& fileName);
// 保存XML文件到fileName,成功返回true,失败返回false
bool SaveToXMLFile(const std::string& fileName);
// 安全释放XML文档
void SafeReleaseXMLDoc();
// 获得XML文件内容
void GetXML(std::string& strXML);
// 在文档pIParentElem元素下添加nodeName节点,值为nodeValue
bool AppendMemberNode( const std::string& nodeName,
const std::string& nodeValue,
IXMLDOMElement* pIParentElem,
IXMLDOMNode** ppOutNewChild=NULL);
bool AppendMemberNode( const std::string& nodeName,
int nodeValue,
IXMLDOMElement* pIParentElem,
IXMLDOMNode** ppOutNewChild=NULL);
bool AppendMemberNode( const std::string& nodeName,
long nodeValue,
IXMLDOMElement* pIParentElem,
IXMLDOMNode** ppOutNewChild=NULL);
bool AppendMemberNode( const std::string& nodeName,
double nodeValue,
IXMLDOMElement* pIParentElem,
IXMLDOMNode** ppOutNewChild=NULL);
bool AppendMemberNode( const std::string& nodeName,
bool nodeValue,
IXMLDOMElement* pIParentElem,
IXMLDOMNode** ppOutNewChild=NULL);
// 为元素pIParentElem添加属性
bool AppendAttributeNode(const std::string& nodeName,
const std::string& nodeValue,
IXMLDOMElement* pIParentElem);
bool AppendAttributeNode(const std::string& nodeName,
int nodeValue,
IXMLDOMElement* pIParentElem);
bool AppendAttributeNode(const std::string& nodeName,
long nodeValue,
IXMLDOMElement* pIParentElem);
bool AppendAttributeNode(const std::string& nodeName,
double nodeValue,
IXMLDOMElement* pIParentElem);
bool AppendAttributeNode(const std::string& nodeName,
bool nodeValue,
IXMLDOMElement* pIParentElem);
// 获取pIParentElem元素下nodeName节点的值
bool GetNodeValue( IXMLDOMNode* pIParentElem,
const std::string& nodeName,
std::string& nodeValue);
bool GetNodeValue( IXMLDOMNode* pIParentElem,
const std::string& nodeName,
int& nodeValue);
bool GetNodeValue( IXMLDOMNode* pIParentElem,
const std::string& nodeName,
long& nodeValue);
bool GetNodeValue( IXMLDOMNode* pIParentElem,
const std::string& nodeName,
double& nodeValue);
bool GetNodeValue( IXMLDOMNode* pIParentElem,
const std::string& nodeName,
bool& nodeValue);
// 获得节点pIParentElem的属性
bool GetAttributeNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
std::string& nodeValue);
bool GetAttributeNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
int& nodeValue);
bool GetAttributeNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
long& nodeValue);
bool GetAttributeNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
double& nodeValue);
bool GetAttributeNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
bool& nodeValue);
// 获得文档元素
IXMLDOMElement* GetDocElem();
// 获得节点的nodeName孩子
IXMLDOMNode* GetChildNode(IXMLDOMNode* pIParentElem,
const std::string& nodeName,
std::string& nodeValue);
protected:
private:
IXMLDOMDocument2* m_pIXMLDoc; // XML文档
};
类以及示例下载
- MSXML类封装
- [c++]一个对MSXML的封装类 使用C++的Smart Pointer 对MSXML DOM封装,可以方便地访问xml文件
- [c++]一个对MSXML的封装类 使用C++的Smart Pointer 对MSXML DOM封装,可以方便地访问xml文件
- [c++]一个对MSXML的封装类 使用C++的Smart Pointer 对MSXML DOM封装,可以方便地访问xml文件
- [c++]一个对MSXML的封装类 使用C++的Smart Pointer 对MSXML DOM封装,可以方便地访问xml文件
- [c++]一个对MSXML的封装类 使用C++的Smart Pointer 对MSXML DOM封装,可以方便地访问xml文件
- MSXML
- MSXML
- msxml
- msxml类的继承关系
- 使用MSXML来保存配置信息的CPP类
- MSXML 嗅探器
- msxml.dll
- MSXML介绍
- 使用MSXML
- 找不到MSXML
- msxml应用
- MSXML介绍 .
- 同步synchronized方法和代码块
- Process Monitor v1.1 By Mark Russinovich and Bryce Cogswell
- if the reference of the thread is set to null.
- SQL 分頁
- 转载:动态语言崛起 Delphi For PHP能否挽救Borland?
- MSXML类封装
- B-树(B-Tree)的C++演示代码
- 抵御内核恶意软件
- Mozilla研究—XPCOM语言无关性的实现原理
- 路由器,交换机,集线器的区别
- 最近时间紧张,正在开发iSpace Desktop 2007....
- 一封给正在寻找工作的大学生的信
- 成功获得客户忠诚的七个阶段
- ERP项目组首次集体活动记