/*GoChildByPath tpath - path of child element (ie. /parentelement[1]/childelement) telement - on success, navigates to element specified by tpath return True if element found */ Bool CXMLElement::GoChildByPath(char *tpath) { if (!isinited()) return False; char *sptr = tpath; char *childpointer = NULL; CXMLElement telement; telement.CopyElement(this); if (*sptr == '/') sptr++; //skip first slash Bool foundmatch = False; char *endptr = sptr + strlen(sptr); while (sptr < endptr) { char *namestart,*nameend,*nextname,*numpointer; nextname = strchr(sptr, '/' ); if (!nextname) nextname = endptr; namestart = sptr; nameend = nextname; bool t_is_text; t_is_text = (nameend == namestart) || (namestart[0] == '['); if (!telement.GoChild(NULL, t_is_text)) return False; int whichchild = 1; numpointer = util_strchr(sptr,'[',nameend-sptr); if (numpointer) { whichchild = strtol((const char *)++numpointer, NULL, 10); nameend = numpointer-1; } Bool foundmatch = False; int childcounter = 0; do { if ((!t_is_text && util_strnicmp(telement.GetName(),namestart,nameend-namestart)==0) || (t_is_text && telement.IsTextNode())) { childcounter++; if (childcounter == whichchild) { sptr = nextname+1; foundmatch = True; } } } while (!foundmatch && telement.GoNext(NULL, t_is_text)); if (!foundmatch) return False; } CopyElement(&telement); return True; }