From 9a8f9dde85b19aab4c30f5f394ea3c168a2b67f8 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 8 Aug 2011 11:33:37 -0400 Subject: [PATCH] don't create empty xml nodes when there is no default value given for them. NULL != "" --- obt/xml.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/obt/xml.c b/obt/xml.c index a8a3a4ae..68e19ba1 100644 --- 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; -- 2.34.1