Android pugixml write xml file

How do you write to a xml file in Android using PugiXML? Reading goes very well this way:

pugi::xml_document doc;

unsigned char* pBuffer = NULL;
unsigned long bufferSize = 0;
pBuffer = cocos2d::CCFileUtils::sharedFileUtils()->getFileData("leveldata.xml", "rb", &bufferSize);

pugi::xml_parse_result result = doc.load_buffer(pBuffer, bufferSize);

But what about writing?

Regards, Gjjansen