The other thread was about the E4X XML class included in Extendscript. You're asking about exporting the InDesign document XML structure. It's confusing, but the two things have nothing in common.
To get what you want, I would apply a transform during export. See http://news.oreilly.com/2008/07/simple-pretty-printing-with-xs.html for an example .xsl file (which you will set in document.xmlExportPreferences.transformFilename; see http://jongware.mit.edu/idcs6js/pc_XMLExportPreference.html )
Sorry, finally I found the solution. I put in the top of my js "#include : my_xsl_script", it's wrong.
then I do this :
allowTransform = true;
transformFilename = File (my_xsl_script);
It works !