本文介绍了是否可以将libxml输出发送到文件句柄?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我先前的问题的简化版本.可能由于情况太过具体而无法允许任何人回答.
This is a simplified version of my earlier question, which may have been too situation specific to allow anyone to answer.
是否可以将libxml输出发送到先前打开的文件(EG stdin)的文件句柄,而不是这些示例?
Is it possible to send libxml output to a file handle of a previously opened file (E.G. stdin) rather than a file name as used in these examples?
如果是,那么它可能会为我先前的查询提供答案.
If it is then it may provide an answer to my earlier query.
版本等语言:CFedora Linux r20阿帕奇2.4.10libxml2
Versions etc.Language: CFedora Linux r20Apache 2.4.10libxml2
推荐答案
这与您发布的链接相同
xmlBufferPtr buf;
/* Create a new XML buffer, to which the XML document will be
* written */
buf = xmlBufferCreate();
if (buf == NULL) {
printf("testXmlwriterMemory: Error creating the xml buffer\n");
return;
}
/* Create a new XmlWriter for memory, with no compression.
* Remark: there is no compression for this kind of xmlTextWriter */
writer = xmlNewTextWriterMemory(buf, 0);
if (writer == NULL) {
printf("testXmlwriterMemory: Error creating the xml writer\n");
return;
}
完成对内存缓冲区的写操作之后
after you finish writing to the memory buffer you can
fprintf(file, "%s", buf->content);
,或者如果您使用的是open
or if you used open
write(fd, buf->content, buf->size);
这篇关于是否可以将libxml输出发送到文件句柄?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!