Improve escaping and add methods for writing pre-escaped/XML values

- Add `writeXML` and `writeRawAttributeString`.
- Escape whitespace in attributes.
- `writeElementString` no longer double-escapes the string.