📄 cbasenode.cpp
字号:
/////////////////////////////////////////////////////////////////////////////////////文件件:CBaseNode.cpp//功能:封装了libxml2对XML进行解析几个方法、取结点、及取结点指定属性的值///////////////////////////////////////////////////////////////////////////////////#include "CBaseNode.h"/////////////////////////////////////////////////////////////////////////////////////void CBaseNode::OpenXMLDoc(const char* xmlFileName){ m_bReady = true; LIBXML_TEST_VERSION xmlKeepBlanksDefault(0); m_Doc = xmlParseFile(xmlFileName); if(m_Doc == NULL) { m_bReady = false; }}/////////////////////////////////////////////////////////////////////////////////////void CBaseNode::CloseXMLDoc(){ xmlCleanupParser();}/////////////////////////////////////////////////////////////////////////////////////void CBaseNode::GetAttributeValue(NODE currentNode, const char* attrName, char* attrValue, const char* delaultValue){ memcpy(attrValue, delaultValue, strlen(delaultValue)); attrValue[strlen(delaultValue)] = 0; _xmlAttr* oneAttr = currentNode->properties; while(oneAttr != NULL) { if(xmlStrcmp(oneAttr->name, (xmlChar* )attrName) == 0) { memset(outValue, 0, MAXATTRVALUELEN); outValueLen = MAXATTRVALUELEN; int inValueLen = (int)strlen((char *)oneAttr->children->content); if(UTF8Toisolat1(outValue, &outValueLen , oneAttr->children->content, &inValueLen) == 0) { outValue[outValueLen] = 0; memcpy(attrValue, (char *)outValue, outValueLen); attrValue[outValueLen] = 0; }else { memcpy(attrValue, (char *)oneAttr->children->content, strlen((char *)oneAttr->children->content)); attrValue[strlen((char *)oneAttr->children->content)] = 0; } break; } oneAttr = oneAttr->next; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -