title: Parse HTML String to DOM and convert it back to string
body: <p>I've got an <code>HTML</code> <code>string</code> e.g. <code>'&lt;p&gt;&lt;span class="text"&gt;Hello World!&lt;/span&gt;&lt;/p&gt;'</code></p>
  
  <p>I parse this <code>HTML</code> <code>string</code> to <code>DOM</code> using <code>DOMParser().parseFromString()</code>, because I want to change the <code>innerHTML</code> of some specific <code>elements</code>. That's why I <code>parse</code> the <code>HTML</code> <code>string</code> to <code>DOM</code> and with <code>getElementByClassName</code> I get all my elements and loop through them to change it <code>innerHTML</code>. This works so far.</p>
  
  <p>After I changed the <code>innerHTML</code>, I try to convert the new <code>DOM</code> back to a <code>string</code>. I can't figure out how. What I tried is to assign the <code>innerHTML</code> or <code>outerHTML</code> (tried both) to a variable like this:</p>
  
  <pre><code>const parser = new DOMParser();
  const doc = parser.parseFromString("&lt;p&gt;Hello World!&lt;/p&gt;", "text/html");
  console.log(doc.innerHTML) // undefined
  console.log(doc.outerHTML) // undefined
  </code></pre>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const parser = new DOMParser();
  const doc = parser.parseFromString("&lt;p&gt;Hello World!&lt;/p&gt;", "text/html");
  console.log(doc.innerHTML) // undefined
  console.log(doc.outerHTML) // undefined</code></pre>
  </div>
  </div>
  </p>
  
  <p>I always get <code>undefined</code>. How can I parse it back to a <code>string</code>? I found a lot examples with <code>innerHTML</code> or <code>outerHTML</code>, but in my case something went wrong. Any ideas?</p>