Rewrite everything

- Use _() instead of magic __call()
- Use DOMImplementation, DOMDocumentType, and DOMDocument to create a
  document instead of constructing the XML header manually
- Use DOMText for node value. No need for manual escaping.