title: JavaScript get data attributes from nodeList?
body: <p>I'm trying to webscrape data attributes.</p>
  
  <pre><code>&lt;div class="class1"&gt;
      &lt;div class="class2"&gt;
          &lt;div data-example="hi"&gt;
  
          &lt;/div&gt; 
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="class1"&gt;
      &lt;div class="class2"&gt;
          &lt;div data-example="hi"&gt;
  
          &lt;/div&gt; 
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>JavaScript</p>
  
  <pre><code>var list = document.querySelectorAll('.class1 .class2');
  console.log(list[list.length - 1]);
  </code></pre>
  
  <p>This returns raw HTML in the console, which I can't use to access the data-attribute values. Unfortunately, I cannot change the format of the HTML and I'm only interested in getting <code>data-example</code> when it's from <code>.class1 .class2</code>.</p>
  
  <p>I'm getting HTML when I access any of the results from <code>querySelectorAll</code>.</p>