diff --git a/mxml.c b/mxml.c index 39fe73c..bb5d601 100755 --- a/mxml.c +++ b/mxml.c @@ -731,7 +731,7 @@ int mxml_find_nodes1(PMXML_NODE tree, char *xml_path, PMXML_NODE **nodelist, int char cond_name[MXML_MAX_CONDITION][256], cond_value[MXML_MAX_CONDITION][256]; int cond_type[MXML_MAX_CONDITION]; int i, j, k, index, num_cond; - int cond_satisfied; + int cond_satisfied,cond_index; size_t len; p1 = xml_path; @@ -808,6 +808,7 @@ int mxml_find_nodes1(PMXML_NODE tree, char *xml_path, PMXML_NODE **nodelist, int } } + cond_index = 0; for (i=j=0 ; in_children ; i++) { if (num_cond) { cond_satisfied = 0; @@ -827,9 +828,13 @@ int mxml_find_nodes1(PMXML_NODE tree, char *xml_path, PMXML_NODE **nodelist, int cond_satisfied++; } } - if (cond_satisfied==num_cond) - if (!mxml_add_resultnode(pnode->child+i, p2, nodelist, found)) - return 0; + if (cond_satisfied==num_cond) { + cond_index++; + if (index == 0 || cond_index == index) { + if (!mxml_add_resultnode(pnode->child+i, p2, nodelist, found)) + return 0; + } + } } else { if (strcmp(pnode->child[i].name, node_name) == 0) if (index == 0 || ++j == index)