title: Retrieve literal value of HTML elements in javascript, without encoding ampersands
body: <p>I'm trying to retrieve the literal contents of some HTML elements, <strong>without encoding ampersands</strong>. I can't seem to find a way to do this.</p>
  
  <p>An example : 
  If I set the URL :</p>
  
  <pre><code>http://www.google.com?q=foo&amp;bla=bar&amp;amp;kitties=yay 
  </code></pre>
  
  <p>on an anchor tag, and try to retrieve it again with innerHTML, or by using XMLSerializer.serializeToString() the URL (as href) comes back as : </p>
  
  <pre><code>http://www.google.com?q=foo&amp;amp;bla=bar&amp;amp;kitties=yay
  </code></pre>
  
  <p>(the first non-encoded ampersand has been encoded, and the encoded ampersand is unchanged[still encoded, not double encoded])</p>
  
  <p>I'm aware that this encoded version the browser gives me back is correct(ed) HTML and wouldn't normally cause problems, but I have people looking at these URLs who do not understand that &amp;amp; is &amp;, and who will copy and paste the URL to verify it. I also don't think its safe to decode the URL as often these URLs have encoded urls on the end, which should remain encoded, and they don't seem to get double-encoded. I suppose this is also incorrect as the URL is corrected and not "encoded" as such. I also need the HTML tag part (e.g. the <code>&lt;a&gt;</code>), so can't just get the nodeValue/innerText/textContent/data .</p>
  
  <p>Any suggestions greatfully received - I'd include a jsfiddle but even that encodes stuff so its not helpful! Sorry if this is obvious, but I'm stuck!</p>