我有下面的程序来标记一个Xpath表达式.但是它不能处理这样的表达式:
/employees/employee[secret-code=a/b/c][unicode=d/e/f]/salary
基本上通过'/'来标记化,因为谓词本身包含'/'.
const char *g_xpath_node_delim = "/";
static void tokenize_xpath (char *xpath_str)
{
const char *tok = NULL;
if (!xpath_str)
return;
while ((tok = strsep(&xpath_str, g_xpath_node_delim)) != NULL) {
if (tok[0] == '\0')
continue;
fprintf(stdout, "\nToken '%s'\n", tok);
}
}
我想构建一个由 node 及其谓词组成的 struct .有什么提示吗?