diff options
| author | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2013-07-30 15:31:26 +0200 |
|---|---|---|
| committer | Benjamin Dauvergne <bdauvergne@entrouvert.com> | 2013-07-30 15:31:26 +0200 |
| commit | f48cd5bbcf19736895d4ebd3f979381a004fcd15 (patch) | |
| tree | aa35df86c8279307aa7aa93b8a42efc463d75728 /bindings/php5/wrapper_source_top.c | |
| parent | 6af73738f660661ce4c4a42e48f561306726d106 (diff) | |
| parent | bd0f935a2450b5779a01e9e5053267ec4cac94d6 (diff) | |
| download | lasso-f48cd5bbcf19736895d4ebd3f979381a004fcd15.tar.gz lasso-f48cd5bbcf19736895d4ebd3f979381a004fcd15.tar.xz lasso-f48cd5bbcf19736895d4ebd3f979381a004fcd15.zip | |
Merge remote-tracking branch 'origin/libxml2.9-compat'
Diffstat (limited to 'bindings/php5/wrapper_source_top.c')
| -rw-r--r-- | bindings/php5/wrapper_source_top.c | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/bindings/php5/wrapper_source_top.c b/bindings/php5/wrapper_source_top.c index 67a279a4..0b1db97d 100644 --- a/bindings/php5/wrapper_source_top.c +++ b/bindings/php5/wrapper_source_top.c @@ -119,31 +119,41 @@ free_glist(GList **list, GFunc free_function) { } /* Conversion functions */ +static xmlBuffer* +xmlnode_to_xmlbuffer(xmlNode *node) +{ + xmlOutputBufferPtr output_buffer; + xmlBuffer *buffer; + + if (! node) + return NULL; + + buffer = xmlBufferCreate(); + output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL); + xmlNodeDumpOutput(output_buffer, NULL, node, 0, 0, NULL); + xmlOutputBufferClose(output_buffer); + xmlBufferAdd(buffer, BAD_CAST "", 1); + + return buffer; +} + static char* get_string_from_xml_node(xmlNode *xmlnode) { - xmlOutputBufferPtr buf; - char *xmlString; + xmlBuffer *buffer; + char *result; if (xmlnode == NULL) { return NULL; } - - buf = xmlAllocOutputBuffer(NULL); - if (buf == NULL) { - xmlString = NULL; + buffer = xmlnode_to_xmlbuffer(xmlnode); + if (buffer == NULL) { + result = NULL; } else { - xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 1, NULL); - xmlOutputBufferFlush(buf); - if (buf->conv == NULL) { - xmlString = estrdup((char*)buf->buffer->content); - } else { - xmlString = estrdup((char*)buf->conv->content); - } - xmlOutputBufferClose(buf); + result = estrdup((char*)xmlBufferContent(buffer)); + xmlBufferFree(buffer); } - - return xmlString; + return result; } static xmlNode* |
