summaryrefslogtreecommitdiff
path: root/src/xml/xml.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-02-06 01:01:22 -0600
committersanine <sanine.not@pm.me>2023-02-06 01:01:22 -0600
commit3d1afa579c9ce045c87e4b68a6d6068a389251a0 (patch)
treee4e569dcd1b6ae798ff59fb640dfb1ab2ff76eed /src/xml/xml.c
parentc5936b5e28c8f81e974bd8d9eb901832921c2b78 (diff)
add kai_tag_get_first_child_with_type() and kai_tag_get_next_sibling_with_type()
Diffstat (limited to 'src/xml/xml.c')
-rw-r--r--src/xml/xml.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/xml/xml.c b/src/xml/xml.c
index 7f101ee..1b369c1 100644
--- a/src/xml/xml.c
+++ b/src/xml/xml.c
@@ -70,3 +70,22 @@ int kai_tag_num_children(struct kai_tag_t *t)
}
return count;
}
+
+
+struct kai_tag_t * kai_tag_get_first_child_with_type(struct kai_tag_t *t, char *type)
+{
+ struct kai_tag_t *child = t->children;
+ for (; child != NULL; child = child->next) {
+ if (strcmp(child->type, type) == 0) { return child; }
+ }
+ return NULL;
+}
+
+
+struct kai_tag_t * kai_tag_get_next_sibling_with_type(struct kai_tag_t *t, char *type)
+{
+ for (t = t->next; t != NULL; t = t->next) {
+ if (strcmp(t->type, type) == 0) { return t; }
+ }
+ return NULL;
+}