⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parsexml.h

📁 一个简单的XML文件生成和解释程序,很实用.
💻 H
字号:
/*
Date:2006-11-18
Description:解析XML数据格式,生成xml格式.
*/
#if !defined(_EP_PARSE_XML_H_)
#define _EP_PARSE_XML_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "ygxml.h"
#include "YGString.h"
#include "NI_Stack.h"
class CXMLNode;
class CXMLValue;
class CXMLValue{
private:
	CYGString m_strName;
	CYGString m_strValue;
public:
	CXMLValue();
	CXMLValue(char *strName,char *strValue);
	~CXMLValue();
public:
    inline CYGString *GetName();
    inline CYGString *GetValue();
	inline void SetName(char *strName);
	inline void SetValue(char *strValue);
};
class CXMLNode{
  private:
     CXMLValue *m_Value;
     CXMLNode  *m_pParent;
	 CNI_Stack *m_Property;
	 CNI_Stack *m_ChildNode;
public:
	CXMLNode(CXMLNode *pParent);
	~CXMLNode();
public:
    CXMLNode *GetParent();
	void      SetParent(CXMLNode *pParent);
	CYGString*GetName();
	void      SetName(char *strName);
	CYGString*GetContext();
	void      SetContext(char *strValue);

    CXMLNode *CreateChildNode(char *strName);
	int       GetChildCount();
	CXMLNode *GetChildNode(char *strName);
	CXMLNode *GetChildNode(int index);	
	bool      RemoveChildNode(char *strName);
	bool      RemoveChildNode(int index);

	CXMLValue*CreateProperty(char *strName,char *strValue);
	int       GetPropertyCount();
	CXMLValue*GetProperty(char *strName);
	CXMLValue*GetProperty(int index);
	bool      RemoveProperty(char *strName);
	bool      RemoveProperty(int index);
};
class CParseXML:public CYgXmlBase  
{
private:
	CNI_Stack *m_Node;
	CNI_Stack *m_Property;
	CXMLNode  *pCurNode;
	CYGString m_Context;
public:
	CParseXML();
	~CParseXML();
private:
	void OnBeginTag(char *strName);
    void OnProperty(char *strPro,char *strValue);
	void OnContext(char *strValue);
	void OnEndTag(char *strName);
	void OnXmlProperty(char *strPro,char *strValue);
	void _XMLContext(CXMLNode *pNode,CYGString &str);
public:
    CXMLNode *CreateChildNode(char *strName);
	int       GetChildCount();
	CXMLNode *GetChildNode(char *strName);
	CXMLNode *GetChildNode(int index);	
	bool      RemoveChildNode(char *strName);
	bool      RemoveChildNode(int index);

	CXMLValue*CreateProperty(char *strName,char *strValue);
	int       GetPropertyCount();
	CXMLValue*GetProperty(char *strName);
	CXMLValue*GetProperty(int index);
	bool      RemoveProperty(char *strName);
	bool      RemoveProperty(int index);
	bool      EmptyXML();
public:
	bool SaveFile(char *strFileName);
	bool GetXMLContext(CYGString &str);
	bool LoadText(char *strContext);
	bool LoadFile(char *strFileName);
};

#endif // !defined(_EP_PARSE_XML_H_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -