Well, the trolls - or better nokias(?) - have something against tree dashes. Have a look at the QDomCommentPrivate::save() implementation:
Qt Code:
  1. if (value.endsWith(QLatin1Char('-')))
  2. s << ' '; // Ensures that XML comment doesn't end with --->
To copy to clipboard, switch view to plain text mode 

So the best would be as you self have written:
Qt Code:
  1. byteArray.replace("<!---", "<!--").replace("--->", "-->")
To copy to clipboard, switch view to plain text mode 

Lykurg

P.s.: I am not sure if three dashes are valid XML even if it is only said that comments starts with "<!--" and ends with "-->"...