284
284
/* xmlNode handling */
286
xmlnode_to_xmlbuffer(xmlNode *node)
288
xmlOutputBufferPtr output_buffer;
294
buffer = xmlBufferCreate();
295
output_buffer = xmlOutputBufferCreateBuffer(buffer, NULL);
296
xmlNodeDumpOutput(output_buffer, NULL, node, 0, 0, NULL);
297
xmlOutputBufferClose(output_buffer);
298
xmlBufferAdd(buffer, BAD_CAST "", 1);
286
304
xml_node_to_jstring(JNIEnv *env, xmlNode *xmlnode, jstring *jstr) {
287
xmlOutputBufferPtr buf = NULL;
289
307
g_error_if_fail(env);
295
buf = xmlAllocOutputBuffer(NULL);
298
xmlNodeDumpOutput(buf, NULL, xmlnode, 0, 1, NULL);
299
xmlOutputBufferFlush(buf);
301
if (buf->conv == NULL) {
302
str = buf->buffer->content;
304
str = buf->conv->content;
306
ret = string_to_jstring(env, (char*)str, jstr);
307
xmlOutputBufferClose(buf);
312
buffer = xmlnode_to_xmlbuffer(xmlnode);
310
314
exception(env, "could not alloc an xml output buffer");
317
return string_to_jstring(env, (char*)xmlBufferContent(buffer), jstr);
316
320
/** Convert a java string to an xml node. Return 0 if it failed with an exception