Beispiel #1
0
clish_xmlnode_t *clish_xmldoc_get_root(clish_xmldoc_t *doc)
{
	if (doc) {
		node_t *root = roxml_get_root(xmldoc_to_node(doc));
		return node_to_xmlnode(root);
	}
	return NULL;
}
Beispiel #2
0
clish_xmlnode_t *clish_xmlnode_parent(clish_xmlnode_t *node)
{
	if (node) {
		node_t *roxn = xmlnode_to_node(node);
		node_t *root = roxml_get_root(roxn);
		if (roxn != root)
			return node_to_xmlnode(roxml_get_parent(roxn));
	}
	return NULL;
}
Beispiel #3
0
node_t ** ROXML_API roxml_xpath(node_t *n, char * path, int *nb_ans)
{
	int index = 0;
	int count = 0;
	xpath_node_t * xpath = NULL;
	node_t ** node_set = NULL;
	node_t * root = n;
	char * full_path_to_find;
	char * path_to_find;

	if(n == NULL)	{ 
		if(nb_ans) { *nb_ans = 0; }
		return NULL; 
	}

	root = roxml_get_root(n);

	full_path_to_find = strdup(path);
	path_to_find = full_path_to_find;

	index = roxml_parse_xpath(path_to_find, &xpath, 0);

	if(index >= 0) {
		node_set = roxml_exec_xpath(root, n, xpath, index, &count);

		roxml_free_xpath(xpath, index);
		free(full_path_to_find);

		if(count == 0)	{
			roxml_release(node_set);
			node_set = NULL;
		}
	}
	if(nb_ans)	{
		*nb_ans = count;
	}

	return node_set;
}