Arrai and me created a class for xml output for mangos some days ago:
Xml.h file: http://paste2.org/p/150797 (stuff this into src/shared/)
an example for how to implement:
http://paste2.org/p/150799
you will need to add this to Xml.h or any suitable included .h file(somehow didnt work for World.h -> its been late that day ;D):
uint16 XmlExportKeys[xml_EXPORT_MAX_INDEX] =
{OBJECT_FIELD_GUID, UNIT_FIELD_LEVEL, UNIT_FIELD_MAXHEALTH, UNIT_FIELD_MAXPOWER1, UNIT_FIELD_MAXPOWER2,
UNIT_FIELD_MAXPOWER3, UNIT_FIELD_MAXPOWER4, UNIT_FIELD_MAXPOWER5, UNIT_FIELD_MAXPOWER6, UNIT_FIELD_MAXPOWER7,
UNIT_FIELD_MINDAMAGE, UNIT_FIELD_MAXDAMAGE, UNIT_FIELD_MINOFFHANDDAMAGE, UNIT_FIELD_MAXOFFHANDDAMAGE, UNIT_FIELD_STAT0,
UNIT_FIELD_STAT1, UNIT_FIELD_STAT2, UNIT_FIELD_STAT3, UNIT_FIELD_STAT4, UNIT_FIELD_ATTACK_POWER, UNIT_FIELD_RANGED_ATTACK_POWER,
PLAYER_GUILDID, PLAYER_GUILDRANK, PLAYER_BLOCK_PERCENTAGE, PLAYER_DODGE_PERCENTAGE, PLAYER_PARRY_PERCENTAGE, PLAYER_EXPERTISE,
PLAYER_CRIT_PERCENTAGE, PLAYER_RANGED_CRIT_PERCENTAGE, PLAYER_SPELL_CRIT_PERCENTAGE1, PLAYER_FIELD_LIFETIME_HONORBALE_KILLS};
char* XmlExportTags[xml_EXPORT_MAX_INDEX] =
{"guid", "level", "maxhealth", "maxpower1", "maxpower2", "maxpower3", "maxpower4", "maxpower5", "maxpower6", "maxpower7",
"mindamage", "maxdamage", "minoffdamage", "maxoffdamage", "stat0", "stat1", "stat2", "stat3", "stat4", "attackpower", "rangedattackpower"
"guildid", "guildrank", "blockpercentage", "dodge", "parry", "expertise", "crit", "rangedcrit", "spellcrit", "honorablekills"};
this will create a players.xml file with all stats mentioned in XmlExportTags plus name and class
have fun with it