title: Extract element by ID from string?
body: <p>I have a string which contains this text:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;ExtractDiv test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;p&gt;Apples and oranges&lt;/p&gt;
      &lt;div id="main"&gt;
          &lt;ul style="list-style-type: upper-roman"&gt;
              &lt;li&gt;&amp;#196;pfel&lt;/li&gt;
              &lt;li&gt;Birnen&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
      &lt;p&gt;Men and women&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now I need a JavaScript function which gives me back a DOM element with a specific ID <strong>as a string</strong> from this text, for example:</p>
  
  <pre><code>function ExtractElementByIdFromString(HTMLString, IdString)
  {
    var ExtractedElement = ???(HTMLString, IdString);
    return ExtractedElement;
  }
  </code></pre>
  
  <p>So the RESULT of this function in this case would be:</p>
  
  <pre><code>&lt;div id="main"&gt;
      &lt;ul style="list-style-type: upper-roman"&gt;
          &lt;li&gt;&amp;#196;pfel&lt;/li&gt;
          &lt;li&gt;Birnen&lt;/li&gt;
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Is this possible?</p>