Что-то, что я написал некоторое время назад.Надеюсь, это поможет ....
xmlDocPtr pDoc = ... // your xml docuemnt
xmlCharPtr psOutput;
int iSize;
xmlDocDumpFormatMemoryEnc(pDoc, &psOutput, &iSize, "UTF-8", 1);
// psOutput should point to the string.
// Don't forget to free the memory.
xmlFree(psOutput);