Use proper XML parsing instead of regular expressions, part 2.

(Now also for the output phase.)