Tidied up XML escape code.