Return TypeFunction nameArguments
hzEcodehzDocXml::FindNodes(hzVect<hzXmlNode*>&,const char*,)

Declared in file: hzDocument.h
Defined in file : hzDocXml.cpp

Function Logic:

0:START 1:hzVect::Clear 2:!srchExp||!srchExp[0] 3:Return E_ARGUMENT 4:cpBuf j 5:*i; 6:*i==(char)61||(*i=='-'&&i[1]=='>') 7:* j tagname 8:i[0]=='-'&&i[1]=='>' 9:*i; 10:*i==(char)61 11:* j attrname 12:*i==(char)61 13:*i&&*i!=(char)34; 14:*i&&*i!=(char)34; 15:* value 16:cpBuf hzMapM::First nLo 17:nLo<0 18:Return E_NOTFOUND 19:hzMapM::Last nHi nIndex 20:nIndex<=nHi; 21:hzMapM::GetObj nodeNo hzArray::InSitu pN bInclude 22:attrname 23:ai.Valid(); 24:hzAttrset::Name anam hzAttrset::Value aval 25:attrname==anam 26:!value||value==aval 27:bInclude 28:!value||pN->m_fixContent==value 29:bInclude 30:bInclude 31:hzVect::Add 32:Return E_OK

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 ;
}