[gupnp-av] Add XML helper function removing child element.
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gupnp-av] Add XML helper function removing child element.
- Date: Fri, 21 Sep 2012 10:50:00 +0000 (UTC)
commit f6f5a2999c94c9718f56b5fb9854d39e95f66920
Author: Krzesimir Nowak <krnowak openismus com>
Date: Fri Sep 7 15:08:22 2012 +0200
Add XML helper function removing child element.
Will be needed for unsetting independent properties.
libgupnp-av/xml-util.c | 19 +++++++++++++++----
libgupnp-av/xml-util.h | 4 ++++
2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/libgupnp-av/xml-util.c b/libgupnp-av/xml-util.c
index 4d345b8..a2cfc16 100644
--- a/libgupnp-av/xml-util.c
+++ b/libgupnp-av/xml-util.c
@@ -65,9 +65,8 @@ xml_util_get_child_elements_by_name (xmlNode *node, const char *name)
GList *children = NULL;
for (node = node->children; node; node = node->next) {
- if (node->name == NULL) {
+ if (node->name == NULL)
continue;
- }
if (strcmp (name, (char *) node->name) == 0) {
children = g_list_append (children, node);
@@ -229,12 +228,11 @@ xml_util_set_child (xmlNode *parent_node,
xmlChar *escaped;
node = xml_util_get_element (parent_node, name, NULL);
- if (node == NULL) {
+ if (node == NULL)
node = xmlNewChild (parent_node,
namespace,
(unsigned char *) name,
NULL);
- }
escaped = xmlEncodeSpecialChars (doc, (const unsigned char *) value);
xmlNodeSetContent (node, escaped);
@@ -243,6 +241,19 @@ xml_util_set_child (xmlNode *parent_node,
return node;
}
+void
+xml_util_unset_child (xmlNode *parent_node,
+ const char *name)
+{
+ xmlNode *node;
+
+ node = xml_util_get_element (parent_node, name, NULL);
+ if (node != NULL) {
+ xmlUnlinkNode (node);
+ xmlFreeNode (node);
+ }
+}
+
gboolean
xml_util_verify_attribute_is_boolean (xmlNode *node,
const char *attribute_name)
diff --git a/libgupnp-av/xml-util.h b/libgupnp-av/xml-util.h
index 80d9b82..4d63dc7 100644
--- a/libgupnp-av/xml-util.h
+++ b/libgupnp-av/xml-util.h
@@ -88,6 +88,10 @@ xml_util_set_child (xmlNode *parent_node,
const char *name,
const char *value);
+G_GNUC_INTERNAL void
+xml_util_unset_child (xmlNode *parent_node,
+ const char *name);
+
G_GNUC_INTERNAL gboolean
xml_util_verify_attribute_is_boolean (xmlNode *node,
const char *attribute_name);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]