title: How can we convert HTML string to Object using javascript?
body: <p>I have an Html string like this:</p>
  
  <pre><code>&lt;div id="foo"&gt;
      &lt;h1 class="greeting"&gt;Hello World!&lt;/h1&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to convert this html string to Object in Javascript. i.e., I should get the same object result when used <code>.children()</code> method in jquery.I tried something like this:</p>
  
  <pre><code>a = '&lt;div id="foo"&gt;
      &lt;h1 class="greeting"&gt;Hello World!&lt;/h1&gt;
  &lt;/div&gt;';
  eval("{"+a+"}");
  console.log(a);
  </code></pre>
  
  <p>But it didn't work. What method should I use in javascript to convert HTML string to Object notation. I should get each children node in object form. I do not want to use Jquery in this solution. I am expecting the exact output as shown in console</p>
  
  <p><img src="https://i.stack.imgur.com/nMmRg.png" alt="enter image description here"></p>