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

📄 xmltools.h

📁 Xerces-C++应用实例
💻 H
字号:
// ================================================================================
//
//    author:         Rainer Schuster
//
//    created:        09.03.2005 10:18:56
//
//    filename:       xmltools.h
//
//    This code is as it is. You are allowed to use, modify and/or redistribute it freely.
//    I'm not responsible for any errors or damage. Use it at your own risk.
//
// ================================================================================





#ifndef _XMLTOOLS_H
#define _XMLTOOLS_H


// ---------------------------------------------------------------------------
//  Includes
// ---------------------------------------------------------------------------

#include <xercesc/dom/DOMDocument.hpp>
#include <xercesc/dom/DOMNodeList.hpp>
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/util/XMLString.hpp>


XERCES_CPP_NAMESPACE_USE

// ============== codesnippet from xerces
// ---------------------------------------------------------------------------
//  This is a simple class that lets us do easy (though not terribly efficient)
//  trancoding of XMLCh data to local code page for display.
// ---------------------------------------------------------------------------
class XStr
{
public :
    // -----------------------------------------------------------------------
    //  Constructors and Destructor
    // -----------------------------------------------------------------------
	
	XStr()
	{
		fLocalForm=NULL;
		fUnicodeForm=NULL;
	}

    XStr(const XMLCh* const toTranscode)
    {
        // Call the private transcoding method
        fLocalForm = XMLString::transcode(toTranscode);
		fUnicodeForm=NULL;
    }

    XStr(const char* const toTranscode)
    {
        // Call the private transcoding method
        fUnicodeForm = XMLString::transcode(toTranscode);
		fLocalForm=NULL;
    }


    ~XStr()
    {
        if (fLocalForm)
		{
			XMLString::release(&fLocalForm);
		}
        if (fUnicodeForm)
		{
			XMLString::release(&fUnicodeForm);
		}
    }


    // -----------------------------------------------------------------------
    //  Getter methods
    // -----------------------------------------------------------------------
    const char* localForm() const
    {
        return fLocalForm;
    }

    const XMLCh* unicodeForm() const
    {
        return fUnicodeForm;
    }


private :
    // -----------------------------------------------------------------------
    //  Private data members
    //
    //  fLocalForm
    //      This is the local code page form of the string.
    // -----------------------------------------------------------------------
    char*   fLocalForm;
    XMLCh*   fUnicodeForm;
};

#define X(str) XStr(str).unicodeForm()
#define XC(str) XStr(str).localForm()


DOMNode *GetFirstNode(const DOMDocument *doc, const char *lpstrName);
bool GetAttributeValue (const DOMNode *nd, const char *lpstrName, char *lpstrValue, int nMaxLen);
bool GetAttributeValue (const DOMNode *nd, const char *lpstrName, long &lValue);
DOMNode *GetFirstSubNode(const DOMNode *nd, const char *lpstrName);
char *XMLDateToDate(const char *lpstrXMLDate);

#endif

⌨️ 快捷键说明

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