title: javascript XMLSerializer special characters in attribute
body: <p>I`ve come across a problem when serializing special characters like TAB, linefeed and carriage return as an attribute value.</p>
  
  <p>According to this <a href="http://www.w3.org/TR/1999/WD-xml-c14n-19991109.html#charescaping" rel="nofollow">http://www.w3.org/TR/1999/WD-xml-c14n-19991109.html#charescaping</a>, these should be encoded as <code>&amp;\#x9;</code>, <code>&amp;\#xA;</code>, and <code>&amp;\#xD;</code> respectively. But calling in chrome:</p>
  
  <pre><code>var root = new DOMParser().parseFromString('&lt;root&gt;&lt;/root&gt;', 'text/xml').documentElement;
  root.setAttribute('a', 'first\nsecond');
  var serialized = new XMLSerializer().serializeToString(root);
  </code></pre>
  
  <p>Gives a string <code>&lt; root a="first\nsecond"/&gt;</code> with the linefeed not escaped.</p>
  
  <p>When loading that again:</p>
  
  <pre><code>var loaded = new DOMParser().parseFromString(serialized, 'text/xml').documentElement;
  loaded.getAttribute('a');
  </code></pre>
  
  <p>returns "first second" and the linefeed was lost to just a space. Has anyone faced this issue before? Any help would be appreciated.</p>
  
  <p>Thanks, </p>
  
  <p>Viktor</p>