util: introduce virXMLNodeContentString

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>
This commit is contained in:
Pavel Hrdina 2017-08-16 10:26:09 +02:00
parent 827cf58d50
commit 561726cd7f
3 changed files with 18 additions and 0 deletions

View File

@ -2954,6 +2954,7 @@ virVHBAPathExists;
virXMLCheckIllegalChars;
virXMLChildElementCount;
virXMLExtractNamespaceXML;
virXMLNodeContentString;
virXMLNodeNameEqual;
virXMLNodeSanitizeNamespaces;
virXMLNodeToString;

View 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

View 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. */