]> saetta.ns0.it Git - libzakutilsjsonxml/commitdiff
Added function Xml::new_text_child.
authorAndrea Zagli <azagli@libero.it>
Thu, 23 Jul 2020 15:33:31 +0000 (17:33 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 23 Jul 2020 15:33:31 +0000 (17:33 +0200)
src/xml.c
src/xml.h

index 0420cacb929e544cc257ad79c9d7a084c9194261..cca59b1fd6d7238701e82b6ec2e67a1ecf3dc9fd 100644 (file)
--- a/src/xml.c
+++ b/src/xml.c
 
 #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)
 {
index bbf9499b87cf385ea61c576f8fca481ff058a246..67d6c3f4d5b066b3f6163084bc7c6f99b3bbb44d 100644 (file)
--- 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);