[xml] problems using xmlSaveFileTo()


I have create a nodes tree using libxml2.4.15 and I
want tu dump it into a buffer in memory, so I think I
have to use xmlSaveFileTo(xmlOutputBufferPtr buf,
xmlDocPtr cur, const char *encoding).

But I have two problems:

a) xmlSaveFileTo() has the following definition:

xmlSaveFileTo(xmlOutputBufferPtr buf, xmlDocPtr cur,
const char *encoding) {
    int ret;
    if (buf == NULL) return(0);
    xmlDocContentDumpOutput(buf, cur, encoding, 0);
    ret = xmlOutputBufferClose(buf);

My program do this:

  buf =

  buf->buffer = xmlBufferCreate();

  if (buf->buffer == NULL)
    printf ("ERROR"\n\n");

  ret = xmlSaveFileTo(buf, arbol, NULL);

printf("XML: %s", buf->buffer->content);

I execute it and I obtain a coredump segmentation
because buf->buffer->content has been free by 
xmlOutputBufferClose(buf) (this function is called by
xmlSaveFileTo() -see the code of xmlSaveFileTo-)

b) if I try to called directly the function
xmlDocContentDumpOutput() I have to copy the
definition  of this function in my program because I
can't find the declaration of the function in any
header file of the library code.

why is called xmlOutputBufferClose(buf) by
I'm doing something wrong?
where is located the declaration of

thanks for your help an time.


Do You Yahoo!?
Yahoo! Messenger
Comunicación instantánea gratis con tu gente.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]