Speed up 40% by using regex to filter invalid XML chars.

A regular expression to filter invalid XML characters
is many times faster than calling a Python function
for each character.