现已完成一部分。用的是 tmpfile 函数成功创建临时文件并修改了文件扩展名。在临时文件中写入内容后,保存为xml格式的文件,便于日后以xml格式读取内容。经查阅,libxml 库中的Save方法均会创建filename文件,而且是用户可见的。若想实现消除操作,需借助Deletefile函数删除该文件,并不是一个fclose关闭并删除临时文件可以完成的。这样一来,临时文件变成了可见文件,这个不是我想要的结果啊!请各位指导,不胜感激!

解决方案 »

  1.   

    难道说只能 tmpfile + open 建立临时文件,然后再 fclose + deletefile 删除文件吗?
      

  2.   

    看看testXmlwriterMemory(const char *file)
    /* Create a new XML buffer, to which the XML document will be
         * written */
        buf = xmlBufferCreate();
    /* Create a new XmlWriter for memory, with no compression.
         * Re: there is no compression for this kind of xmlTextWriter */
        writer = xmlNewTextWriterMemory(buf, 0);
    //
        (const char *) buf->content;
        xmlBufferFree(buf);