don't create empty xml nodes when there is no default value given for them. NULL...
authorDana Jansens <danakj@orodu.net>
Mon, 8 Aug 2011 15:33:37 +0000 (11:33 -0400)
committerDana Jansens <danakj@orodu.net>
Sun, 16 Oct 2011 22:56:02 +0000 (18:56 -0400)
obt/xml.c

index a8a3a4aee23478000a539da3d7d10e5475d1d71b..68e19ba1e964930c82b2c207fe064528fb159375 100644 (file)
--- a/obt/xml.c
+++ b/obt/xml.c
@@ -491,14 +491,19 @@ xmlNodePtr obt_xml_path_get_node(xmlNodePtr subtree, const gchar *path,
         if (!c) {
             gint i;
 
-            c = xmlNewTextChild(n, NULL, (xmlChar*)attrs[0],
-                                *next ? NULL : (xmlChar*)default_value);
-
-            for (i = 1; attrs[i]; ++i) {
-                gchar **eq = g_strsplit(attrs[i], "=", 2);
-                if (eq[1])
-                    xmlNewProp(c, (xmlChar*)eq[0], (xmlChar*)eq[1]);
-                g_strfreev(eq);
+            if (*next)
+                c = xmlNewTextChild(n, NULL, (xmlChar*)attrs[0], NULL);
+            else if (default_value)
+                c = xmlNewTextChild(n, NULL, (xmlChar*)attrs[0],
+                                    (xmlChar*)default_value);
+
+            if (c) {
+                for (i = 1; attrs[i]; ++i) {
+                    gchar **eq = g_strsplit(attrs[i], "=", 2);
+                    if (eq[1])
+                        xmlNewProp(c, (xmlChar*)eq[0], (xmlChar*)eq[1]);
+                    g_strfreev(eq);
+                }
             }
         }
         n = c;