fixed escaping of text value in XML element

I'm not clear what the goal of the current implementation was, but I think this one would fix http://stackoverflow.com/questions/552957