const char *GException::ToXML(const char *pzExceptionParent/* = "TransactResultSet"*/) 
{
	_ret.Empty();

	// Get the user stack into strUserStack
	GString strUserStack;
	GStringIterator it(&_ErrorDetail);
	while (it())
	{
		strUserStack += "\t\t<UserStack>";
		strUserStack.AppendEscapeXMLReserved(it++);
		strUserStack += "</UserStack>";
		if (it())
			strUserStack += "\n";
	}


	GString strDescription = (const char *)*this;
	strDescription.EscapeXMLReserved();
	

	_ret.Format("<%s>\n\t<Exception>\n\t\t<Description>%s</Description>\n\t\t"
				"<ErrorNumber>%ld</ErrorNumber>\n\t\t<SubSystem>%d</SubSystem>\n%s\t</Exception></%s>",
				pzExceptionParent,
				(const char *)strDescription,
				(int)_error,
				(int)_subSystem,
				(const char *)strUserStack,
				pzExceptionParent);


	return (const char *)_ret; 
}