Reading this snippet makes me sad. I wish we had used XStream or something to do this from the beginning.