Return Type | Function name | Arguments |
---|---|---|
hzXmlNode* | hzXmlNode::FindSubnode | (const char*,) |
Declared in file: hzDocument.h
Defined in file : hzDocXml.cpp
Function Logic:
Function body:
hzXmlNode* hzXmlNode::FindSubnode (const char* srchExp) { hzXmlNode* pResult ; char* cpBuf ; const char* i ; const char* x ; char* j ; hzString tagname ; hzString attrname ; hzString value ; bool bMatch ; /* ** ** Create a temp buffer ** */ cpBuf = new char[strlen(srchExp) + 1]; /* ** ** We first check for criteria of the form tagname.tagname ..... ** ** If we do have this we have to recurse this function ** */ x = strchr(srchExp, CHAR_PERIOD) ; if (x) { i = srchExp ; j = cpBuf ; for (; *i && *i != CHAR_PERIOD ;) *j++ = *i++ ; *j = 0; tagname = cpBuf ; pResult = _findsubnode(bMatch, tagname, attrname, value) ; delete cpBuf ; if (pResult && bMatch) return pResult->FindSubnode(x + 1); return 0; } /* ** ** Objain the tagname, any attribute name and value from the criteria ** */ i = srchExp ; j = cpBuf ; for (; *i ; i++) { if (*i == CHAR_EQUAL || (*i == ''-''&&i[1]== ''>'')) break ; *j++ = *i ; } *j = 0; tagname = j = cpBuf ; if (i[0]== ''-''&&i[1]== ''>'') { for (i += 2; *i ; i++) { if (*i == CHAR_EQUAL) break ; *j++ = *i ; } *j = 0; attrname = j = cpBuf ; } if (*i == CHAR_EQUAL) { for (i++ ; *i && *i != CHAR_SQUOTE ; i++) ; for (i++ ; *i ; i++) { if (*i == CHAR_SQUOTE) break ; *j++ = *i ; } *j = 0; value = cpBuf ; } delete cpBuf ; /* ** ** Find the subnode by recursive search ** */ pResult = _findsubnode(bMatch, tagname, attrname, value) ; if (pResult && bMatch) return pResult ; return 0; }