Rapidxml references to the pointers of your vector buffer every time you pass an xml. So store both your buffers and also the xml_document<> docs.
Put the filepaths of your xml docs
char *XMLFilePaths[numXmlDocs] = {"../PersonDatasetA/xmlFile.xml","../PersonDatasetB/xmlFile.xml"};
Store both the buffers and also the xml documents into arrays
std::array<vector<char>,numXmlDocs> XMLDocBuffers;
std::array<xml_document<>,numXmlDocs> XMLDocs;
//For each xml doc, read and store it in an array
for(int i=0;i<numXmlDocs;i++){
//Parse each xml into the buffer array
char xmlFileName[100] ;
sprintf(xmlFileName,"%s",XMLFilePaths[i]);
ifstream theFile (xmlFileName);
vector<char> buffer((istreambuf_iterator<char>(theFile)), istreambuf_iterator<char>());
buffer.push_back('\0');
//Store the buffer
XMLDocBuffers[i] = buffer;
// Parse the buffer usingthe xml file parsing library into doc
XMLDocs[i].parse<0>(&(XMLDataset_StringDocs[i][0]));
xml_node<> *root_node; // Find the root node
root_node = (XMLDocs[i]).first_node(typesOfSamples);