title: PowerShell HTML method getElementsByClassName returns null
body: <p>I'm trying to write a PowerShell script which fetches an HTML page from a website and extracts some information from it.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>$html = (invoke-webrequest -uri $address).parsedHTML;
  $bodyHTML = $html.body.getElementsByClassName("news-item")[0].innerText;
  </code></pre>
  
  <p>The script fetches the website fine. The important part of the website looks like this:</p>
  
  <pre><code>...
  &lt;DIV class=news-item&gt;
  Important Information
  ...
  </code></pre>
  
  <p>The Problem:
  I always get an error message: "cannot index into a null array".
  The getElementsByClassName()-Function does not return anything. </p>
  
  <p>If I list all div's and show the class names:</p>
  
  <pre><code>$html.body.getElementsByTagName("div") | select className
  </code></pre>
  
  <p>it lists all the class names including "news-item", which I am looking for.</p>
  
  <p>Does anybody have an idea what the problem might be?</p>