size_t size = sizeof(source);
This line is incorrect. source is treated as a pointer to char, so sizeof is always 4 (or 8) => you only get the first 4/8 bytes parsed. Since you're passing an incomplete buffer to pugixml (likely "<?xm"), pugixml flags it as incorrect.
You have to pass the correct buffer size to your function, or, if the buffer is guaranteed to be null-terminated (not sure how you get the buffer), you can use doc.load(source) instead of doc.load_buffer(source, size).