summaryrefslogtreecommitdiff
path: root/source/fitz/xml.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/fitz/xml.c')
-rw-r--r--source/fitz/xml.c45
1 files changed, 36 insertions, 9 deletions
diff --git a/source/fitz/xml.c b/source/fitz/xml.c
index 5cdaa673..0d370331 100644
--- a/source/fitz/xml.c
+++ b/source/fitz/xml.c
@@ -123,50 +123,77 @@ void fz_debug_xml(fz_xml *item, int level)
fz_xml *fz_xml_prev(fz_xml *item)
{
- return item->prev;
+ return item ? item->prev : NULL;
}
fz_xml *fz_xml_next(fz_xml *item)
{
- return item->next;
+ return item ? item->next : NULL;
}
fz_xml *fz_xml_up(fz_xml *item)
{
- return item->up;
+ return item ? item->up : NULL;
}
fz_xml *fz_xml_down(fz_xml *item)
{
- return item->down;
+ return item ? item->down : NULL;
}
char *fz_xml_text(fz_xml *item)
{
- return item->text;
+ return item ? item->text : NULL;
}
char *fz_xml_tag(fz_xml *item)
{
- if (item->name[0])
- return item->name;
- return NULL;
+ return item && item->name[0] ? item->name : NULL;
}
int fz_xml_is_tag(fz_xml *item, const char *name)
{
- return item->name && !strcmp(item->name, name);
+ if (!item)
+ return 0;
+ return !strcmp(item->name, name);
}
char *fz_xml_att(fz_xml *item, const char *name)
{
struct attribute *att;
+ if (!item)
+ return NULL;
for (att = item->atts; att; att = att->next)
if (!strcmp(att->name, name))
return att->value;
return NULL;
}
+fz_xml *fz_xml_find(fz_xml *item, const char *tag)
+{
+ while (item)
+ {
+ if (!strcmp(item->name, tag))
+ return item;
+ item = item->next;
+ }
+ return NULL;
+}
+
+fz_xml *fz_xml_find_next(fz_xml *item, const char *tag)
+{
+ if (item)
+ item = item->next;
+ return fz_xml_find(item, tag);
+}
+
+fz_xml *fz_xml_find_down(fz_xml *item, const char *tag)
+{
+ if (item)
+ item = item->down;
+ return fz_xml_find(item, tag);
+}
+
static void xml_free_attribute(fz_context *ctx, struct attribute *att)
{
while (att) {