Rewrite the decoding part of XML generator