?? xmltools.cpp
字號:
// ================================================================================
//
// author: Rainer Schuster
//
// created: 09.03.2005 10:19:07
//
// filename: xmltools.cpp IMPLEMENTATION
//
// 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.
//
// ================================================================================
#include "stdafx.h"
#include <xercesc/dom/DOMNamedNodeMap.hpp>
#include "xmltools.h"
DOMNode *GetFirstNode(const DOMDocument *doc, const char *lpstrName)
{
DOMNodeList *nd=doc->getElementsByTagName(X(lpstrName));
if (nd->getLength()>0)
{
return nd->item(0);
}
else
{
return NULL;
}
}
bool GetAttributeValue (const DOMNode *nd, const char *lpstrName, char *lpstrValue, int nMaxLen)
{
memset (lpstrValue,0,nMaxLen);
if (nd)
{
DOMNode *stnd=nd->getAttributes()->getNamedItem(X(lpstrName));
if (stnd)
{
strcpy (lpstrValue,XC(stnd->getNodeValue()));
return true;
}
}
return false;
}
bool GetAttributeValue (const DOMNode *nd, const char *lpstrName, long &lValue)
{
if (nd)
{
DOMNamedNodeMap *attributes = nd->getAttributes();
if( attributes )
{
DOMNode *stnd=attributes->getNamedItem(X(lpstrName));
if (stnd)
{
lValue = atoi( XC(stnd->getNodeValue()) );
return true;
}
}
}
return false;
}
DOMNode *GetFirstSubNode(const DOMNode *nd, const char *lpstrName)
{
DOMNode *rc=NULL;
DOMNodeList *cndl=nd->getChildNodes();
for (UINT i=0; i<cndl->getLength(); i++)
{
DOMNode *p=cndl->item(i);
if (strcmp (XC(p->getNodeName()),lpstrName)==0)
{
rc=p;
}
}
return rc;
}
char *XMLDateToDate(const char *lpstrXMLDate)
{
// Format YYYY-MM-DD
// in DD.MM.YYYY
static char lcReturn[128];
memset (lcReturn,0,128);
strcpy (lcReturn,lpstrXMLDate+8);
strcat (lcReturn,".");
strncat (lcReturn,lpstrXMLDate+5,2);
strcat (lcReturn,".");
strncat (lcReturn,lpstrXMLDate,4);
return lcReturn;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -