I've configured libxml2 with " --with-minimum -with--schemas "
switches (configuration options).
I am using "xmlNewNode" "xmlAddChild" etc. functions to generate the XML file.
Now, i want to save the XML to a file, but i didn't find any function to do that.
Of-course, there are plenty of functions (like xmlSaveFile() etc..) in "libxml2 full version" BUT as i said i've configured it with --minimum
configuration option (b/c of memory constraints).
Any one with help ? Thanks !
xmlDocDumpMemory will let you get the whoe xml doc as a xmlChar*
xmlChar *xmlbuff;
int buffersize;
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
after which you can save it as a file using
FILE *fp;
fp = fopen(file, "w+");
if(!fp){
printf("Could not open file for writing\n");
return;
}
fprintf(fp, buf);
fclose(fp);