From: Andreas Hofmeister Date: Sun, 28 Feb 2010 16:45:12 +0000 (+0100) Subject: Add the text output label as "label" attribute to all xml elements. X-Git-Tag: 0.5.0~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3822145901cc3d4b130370edbf653e306d15ebdb;p=thirdparty%2Flldpd.git Add the text output label as "label" attribute to all xml elements. Might be helpful when creating html via xslt etc. --- diff --git a/src/xml_writer.c b/src/xml_writer.c index e7d2eed6..2e9d0ab4 100644 --- a/src/xml_writer.c +++ b/src/xml_writer.c @@ -34,6 +34,11 @@ void xml_start(struct writer * w , const char * tag, const char * descr ) { if (xmlTextWriterStartElement(p->xw, BAD_CAST tag) < 0) LLOG_WARN("cannot start '%s' element\n", tag); + + if ( descr && (strlen(descr) > 0) ) { + if (xmlTextWriterWriteFormatAttribute(p->xw, BAD_CAST "label", "%s", descr) < 0) + LLOG_WARN("cannot add attribute 'label' to element %s\n", tag); + } } void xml_attr(struct writer * w, const char * tag, const char * descr, const char * value ) {