diff options
Diffstat (limited to 'src/common/xml.c')
-rw-r--r-- | src/common/xml.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/src/common/xml.c b/src/common/xml.c index eb450e0..a90bc65 100644 --- a/src/common/xml.c +++ b/src/common/xml.c @@ -878,7 +878,7 @@ bool add_content_to_node(xmlDocPtr xdoc, xmlXPathContextPtr context, const char * * ******************************************************************************/ -bool add_string_attribute_to_node(xmlNodePtr node, const char *name, const char *value) +bool _add_string_attribute_to_node(xmlNodePtr node, const char *name, const char *value) { xmlAttrPtr attrib; /* Attribut créé et en place */ @@ -891,6 +891,39 @@ bool add_string_attribute_to_node(xmlNodePtr node, const char *name, const char /****************************************************************************** * * +* Paramètres : xdoc = structure XML chargée. * +* context = contexte à utiliser pour les recherches. * +* path = chemin d'accès au noeud visé. * +* name = nom de la propriété à créer. * +* value = chaîne de caractère à placer. * +* * +* Description : Ajoute une propriété à un noeud existant donné. * +* * +* Retour : true en cas de succès, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_string_attribute_to_node(xmlDocPtr xdoc, xmlXPathContextPtr context, const char *path, const char *name, const char *value) +{ + xmlNodePtr node; /* Noeud à modifier */ + xmlAttrPtr attrib; /* Attribut créé et en place */ + + if (value == NULL) return true; + + node = ensure_node_exist(xdoc, context, path); + if (node == NULL) return false; + + attrib = xmlSetProp(node, BAD_CAST name, BAD_CAST value); + + return (attrib != NULL); + +} + + +/****************************************************************************** +* * * Paramètres : node = noeud dont le contenu est à mettre à jour. * * name = nom de la propriété à créer. * * value = valeur numérique à placer. * @@ -909,6 +942,6 @@ bool add_long_attribute_to_node(xmlNodePtr node, const char *name, long value) snprintf(tmp, 11, "%ld", value); - return add_string_attribute_to_node(node, name, tmp); + return _add_string_attribute_to_node(node, name, tmp); } |