Improving XML output

Encoding user name and improving anonymous user handling