From d981f0d887766ef84759eb1e9dc0a7ac098b27cd Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Thu, 23 Jul 2020 17:33:31 +0200 Subject: [PATCH] Added function Xml::new_text_child. --- src/xml.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/xml.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/src/xml.c b/src/xml.c index 0420cac..cca59b1 100644 --- a/src/xml.c +++ b/src/xml.c @@ -22,6 +22,46 @@ #include "xml.h" +xmlNode +*zak_utils_new_text_child (xmlNode *xnode, const xmlChar *name, const xmlChar *content, ...) +{ + xmlNode *cur; + + va_list ap; + + xmlChar *prop; + xmlChar *value; + + cur = xmlNewTextChild (xnode, + NULL, + name, + content); + + va_start (ap, content); + do + { + prop = va_arg (ap, xmlChar *); + if (prop != NULL) + { + value = va_arg (ap, xmlChar *); + if (value != NULL) + { + xmlSetProp (cur, prop, value); + } + else + { + break; + } + } + else + { + break; + } + } while (TRUE); + + return cur; +} + xmlNodeSet *zak_utils_xml_filter (xmlDoc *xdoc, xmlNode *xnode, const xmlChar *filter) { diff --git a/src/xml.h b/src/xml.h index bbf9499..67d6c3f 100644 --- a/src/xml.h +++ b/src/xml.h @@ -30,6 +30,8 @@ G_BEGIN_DECLS +xmlNode *zak_utils_new_text_child (xmlNode *xnode, const xmlChar *name, const xmlChar *content, ...); + xmlNodeSet *zak_utils_xml_filter (xmlDoc *xdoc, xmlNode *xnode, const xmlChar *filter); -- 2.49.0