<libroxml  version="3.0.2" />
contact: tristan.lelong@libroxml.net
roxml_nav.c
Go to the documentation of this file.
1
12#include "roxml_internal.h"
13
15{
16 node_t *prev = NULL;
17 node_t *prev_elm = NULL;
18
19 if (n == ROXML_INVALID_DOC)
20 return ROXML_INVALID_DOC;
21
22 if (n->prnt) {
23 prev = n->prnt->chld;
24 while (prev && prev != n) {
25 if ((prev->type & ROXML_NODE_TYPES) == ROXML_ELM_NODE) {
26 prev_elm = prev;
27 }
28 prev = prev->sibl;
29 }
30 }
31 return prev_elm;
32}
33
35{
36 if (n == ROXML_INVALID_DOC)
37 return ROXML_INVALID_DOC;
38
39 while (n->sibl && (n->sibl->type & ROXML_NODE_TYPES) != ROXML_ELM_NODE) {
40 n = n->sibl;
41 }
42 return n->sibl;
43}
44
46{
47 if (n == ROXML_INVALID_DOC)
48 return ROXML_INVALID_DOC;
49
50 if (n->prnt == NULL)
51 return n;
52 return n->prnt;
53}
54
56{
57 node_t *root;
58
59 if (n == ROXML_INVALID_DOC)
60 return ROXML_INVALID_DOC;
61
62 root = n;
63 while (root->prnt)
64 root = root->prnt;
65 return root;
66}
#define ROXML_INVALID_DOC
Definition roxml.h:235
#define ROXML_ELM_NODE
Definition roxml.h:70
#define ROXML_API
Definition roxml.h:24
#define ROXML_NODE_TYPES
Definition roxml.h:158
internal header required by all libroxml sources
ROXML_API node_t * roxml_get_prev_sibling(node_t *n)
prev sibling getter function
Definition roxml_nav.c:14
ROXML_API node_t * roxml_get_root(node_t *n)
root getter function
Definition roxml_nav.c:55
ROXML_API node_t * roxml_get_next_sibling(node_t *n)
next sibling getter function
Definition roxml_nav.c:34
ROXML_API node_t * roxml_get_parent(node_t *n)
parent getter function
Definition roxml_nav.c:45
node_t structure
struct node * prnt
unsigned short type
struct node * sibl