summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-04-10 13:51:01 +0200
committerDavid Sommerseth <davids@redhat.com>2009-04-29 11:22:12 +0200
commit62f276eea2d8477854d7fe9b230a957a8df4102c (patch)
tree2f175f1453c4d67694215b65f0b699fe28c54e80
parentb8bcbc709a3bdb5ee1e59e22d5e54c59f391165f (diff)
downloadpython-dmidecode-62f276eea2d8477854d7fe9b230a957a8df4102c.tar.gz
python-dmidecode-62f276eea2d8477854d7fe9b230a957a8df4102c.tar.xz
python-dmidecode-62f276eea2d8477854d7fe9b230a957a8df4102c.zip
Do not add XML values if input is "(null)"
-rw-r--r--src/dmixml.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dmixml.c b/src/dmixml.c
index 08c5259..1fe862d 100644
--- a/src/dmixml.c
+++ b/src/dmixml.c
@@ -79,7 +79,8 @@ xmlAttr *dmixml_AddAttribute(xmlNode *node, const char *atrname, const char *fmt
val_s = dmixml_buildstr(2048, fmt, ap);
va_end(ap);
- res = xmlNewProp(node, atrname_s, val_s);
+ res = xmlNewProp(node, atrname_s,
+ (xmlStrcmp(val_s, (xmlChar *) "(null)") == 0 ? NULL : val_s));
free(atrname_s);
free(val_s);
@@ -112,7 +113,9 @@ xmlNode *dmixml_AddTextChild(xmlNode *node, const char *tagname, const char *fmt
val_s = dmixml_buildstr(2048, fmt, ap);
va_end(ap);
- res = xmlNewTextChild(node, NULL, tagname_s, val_s);
+ // Do not add any contents if the string contents is "(null)"
+ res = xmlNewTextChild(node, NULL, tagname_s,
+ (xmlStrcmp(val_s, (xmlChar *) "(null)") == 0 ? NULL : val_s));
free(tagname_s);
free(val_s);
@@ -141,7 +144,11 @@ xmlNode *dmixml_AddTextContent(xmlNode *node, const char *fmt, ...)
val_s = dmixml_buildstr(2048, fmt, ap);
va_end(ap);
- res = xmlAddChild(node, xmlNewText(val_s));
+ if( xmlStrcmp(val_s, (xmlChar *) "(null)") != 0 ) {
+ res = xmlAddChild(node, xmlNewText(val_s));
+ } else {
+ res = node;
+ }
free(val_s);
assert( res != NULL );