]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: introduce virXMLNodeContentString
authorPavel Hrdina <phrdina@redhat.com>
Wed, 16 Aug 2017 08:26:09 +0000 (10:26 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 17 Aug 2017 13:42:23 +0000 (15:42 +0200)
It's equivalent of calling virXPathString("string(.)", ctxt) but it
doesn't have to use the XPath resolving and parsing.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/libvirt_private.syms
src/util/virxml.c
src/util/virxml.h

index 5f6398fc1234d089609affbf452b8e0407c84f2a..7b477a561ebe33e907f47ac53b2a9c7766077742 100644 (file)
@@ -2954,6 +2954,7 @@ virVHBAPathExists;
 virXMLCheckIllegalChars;
 virXMLChildElementCount;
 virXMLExtractNamespaceXML;
+virXMLNodeContentString;
 virXMLNodeNameEqual;
 virXMLNodeSanitizeNamespaces;
 virXMLNodeToString;
index d7a8f7267baecca08639b21b2d3bb56d572259cf..562a4bf3bad44ce7c12267c80021d33b3c74c2cd 100644 (file)
@@ -540,6 +540,22 @@ virXMLPropStringLimit(xmlNodePtr node,
 }
 
 
+/**
+ * virXMLNodeContentString:
+ * @node: XML dom node pointer
+ *
+ * Convenience function to return copy of content of an XML node.
+ *
+ * Returns the content value as string or NULL in case of failure.
+ * The caller is responsible for freeing the returned buffer.
+ */
+char *
+virXMLNodeContentString(xmlNodePtr node)
+{
+    return (char *)xmlNodeGetContent(node);
+}
+
+
 /**
  * virXPathBoolean:
  * @xpath: the XPath string to evaluate
index 1ecc6b0a6179c0dc530008efe52736517939a64d..86baeb37a75113dd8237814d5c00a5550a7b216a 100644 (file)
@@ -76,6 +76,7 @@ char *          virXMLPropString(xmlNodePtr node,
 char *     virXMLPropStringLimit(xmlNodePtr node,
                                  const char *name,
                                  size_t maxlen);
+char *   virXMLNodeContentString(xmlNodePtr node);
 long     virXMLChildElementCount(xmlNodePtr node);
 
 /* Internal function; prefer the macros below.  */