From 29adc0b8f9b0db2c00851df0d1fc9a7a2f0e02a1 Mon Sep 17 00:00:00 2001 From: Matthias Schneebeli Date: Tue, 7 Mar 2006 15:06:59 +0000 Subject: [PATCH] mxml_find_nodes1 able to analyze e.g. [name='XX'][2] --- mxml.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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)