I wonder if we can do this faster than using regular expressions. It may potentially be used very often during XML creation.

@brendo?