Return Type | Function name | Arguments |
---|---|---|
hzEcode | hzDocXml::FindNodes | (hzVect<hzXmlNode*>&,const char*,) |
Declared in file: hzDocument.h
Defined in file : hzDocXml.cpp
Function Logic:
Function body:
hzEcode hzDocXml::FindNodes (hzVect<hzXmlNode*>& Nodes, const char* srchExp) { _hzfunc("hzDocXml::FindNodes") ; hzAttrset ai ; hzXmlNode* pN ; const char* anam ; const char* aval ; const char* i ; char* j ; char* cpBuf ; hzString tagname ; hzString attrname ; hzString value ; uint32_t nodeNo ; uint32_t nLo ; uint32_t nHi ; uint32_t nIndex ; bool bInclude ; Nodes.Clear() ; if (!srchExp || !srchExp[0]) return E_ARGUMENT ; /* ** ** Objain the tagname, any attribute name and value from the criteria ** */ j = cpBuf = new char[strlen(srchExp) + 1]; for (i = srchExp ; *i ; *j++ = *i++) { if (*i == CHAR_EQUAL || (*i == ''-''&&i[1]== ''>'')) break ; } *j = 0; tagname = j = cpBuf ; if (i[0]== ''-''&&i[1]== ''>'') { for (i += 2; *i ; *j++ = *i++) { if (*i == CHAR_EQUAL) break ; } *j = 0; attrname = j = cpBuf ; } if (*i == CHAR_EQUAL) { for (i++ ; *i && *i != CHAR_DQUOTE ; i++) ; for (i++ ; *i && *i != CHAR_DQUOTE ; *j++ = *i++) ; *j = 0; value = cpBuf ; } delete cpBuf ; /* ** ** First obtain the nodes ** */ nLo = m_NodesName.First(tagname) ; if (nLo < 0) { threadLog("Cannot locate a tag of [%s] in tree\n", *tagname) ; return E_NOTFOUND ; } nHi = m_NodesName.Last(tagname) ; for (nIndex = nLo ; nIndex <&eq; nHi ; nIndex++) { nodeNo = m_NodesName.GetObj(nIndex) ; pN = m_arrNodes.InSitu(nodeNo-1); bInclude = false ; if (attrname) { for (ai = pN ; ai.Valid() ; ai.Advance()) { anam = ai.Name() ; aval = ai.Value() ; if (attrname == anam) { if (!value || value == aval) bInclude = true ; break ; } } } else { if (!value || pN->m_fixContent == value) bInclude = true ; } if (bInclude) Nodes.Add(pN) ; } return E_OK ; }