library/src/blockclass/subclasses/BP_StringUtils.cc
//gets an xml element by name or NULL if failed.
gets an xml element by name or NULL if failed.
gets an xml element by name or NULL if failed .
xmlNode * BP_StringUtils::xmlGetElementNodeByNamePCRE(char * pcre_regexp)
{
	if(!this->xml_parsed_ok)
		return NULL;
	if(!this->xml_curr_node)
		return NULL;
	xmlNode * xml_node = this->xml_curr_node;
	for(; xml_node; xml_node = xml_node->next)
	{
		if (xml_node->type == XML_ELEMENT_NODE)
		{
			size_t name_len = 0;
			if(xml_node->name)
			{
				name_len = strnlen((char *) xml_node->name, 8096);
				BP_REGEX_MATCH_INFO match_info;
				memset(&match_info, 0x00, sizeof(match_info));
				if(BP_MatchRegularExpressionPCRE((char *) xml_node->name, name_len, pcre_regexp, 0, 1024, &match_info, 0) == ERR_SUCCESS)
				{
					BP_DestroyRegexpMatchInfo(&match_info);
					return xml_node;
				}
				BP_DestroyRegexpMatchInfo(&match_info);
			}
		}
	}
	return NULL;
}
xmlNode * BP_StringUtils :: xmlGetElementNodeByNamePCRE ( char * pcre_regexp ) { if ( ! this -> xml_parsed_ok ) return NULL ; if ( ! this -> xml_curr_node ) return NULL ; xmlNode * xml_node = this -> xml_curr_node ; for ( ; xml_node ; xml_node = xml_node -> next ) { if ( xml_node -> type == XML_ELEMENT_NODE ) { size_t name_len = 0 ; if ( xml_node -> name ) { name_len = strnlen ( ( char * ) xml_node -> name , 8096 ) ; BP_REGEX_MATCH_INFO match_info ; memset ( & match_info , 0x00 , sizeof ( match_info ) ) ; if ( BP_MatchRegularExpressionPCRE ( ( char * ) xml_node -> name , name_len , pcre_regexp , 0 , 1024 , & match_info , 0 ) == ERR_SUCCESS ) { BP_DestroyRegexpMatchInfo ( & match_info ) ; return xml_node ; } BP_DestroyRegexpMatchInfo ( & match_info ) ; } } } return NULL ; }
gets an xml element by name or NULL if failed.
gets an xml element by name or NULL if failed .
// ensure we have parsed xml // check that we have a root node // set a temp node from current // walk xml nodes // ensure we have a node element // set name length // calculate name // set name length // create new match structure (required for regexp search) // attempt to match node by provided regexp // destroy match information // return the matched node // destroy regular expression match information // return the node