Improved XML and DOCTYPE declaration handling (#22)