title: Get attribute string value from html
body: <p>I am building a macro to extract data from website using <a href="/questions/tagged/vba" class="post-tag" title="show questions tagged 'vba'" rel="tag">vba</a>. Currently I can easily get value from table content using element syntax like <code>obj.getElementsByTagName("td").innerText</code>. However, when there are some non-innerText data in some cells, I am getting trouble. It's like this:</p>
  
  <pre><code>&lt;img src="/images/amber_pending.gif" border="0" alt="Pending" title="Pending"&gt;
  </code></pre>
  
  <p>I attempted to extract the attribute value from "title" using syntax I found from others:</p>
  
  <pre><code>For Each tbObj In doc.getElementsByClassName("report removeTdBorder")
      i = 1
      For Each trObj In tbObj.getElementsByTagName("tr")
          If i &gt;= 3 Then
              j = 1
              For Each tdObj In trObj.getElementsByTagName("td")
                  If j = 1 Then
                      Set imgObj = tdObj.getElementsByTagName("img")
                      dataArray(i, j) = imgObj.getAttribute("title")
                      Debug.Print imgObj.getAttribute("title")
                      ActiveCell.Offset(0, j) = dataArray(i, j)
                      ActiveCell.Offset(0, j).WrapText = False
                  Else
                      dataArray(i, j) = tdObj.innerText
                      Debug.Print i &amp; ", " &amp; j &amp; ": " &amp; dataArray(i, j)
                      ActiveCell.Offset(0, j) = dataArray(i, j)
                      ActiveCell.Offset(0, j).WrapText = False
                  End If
                  j = j + 1
              Next tdObj
              ActiveCell.Offset(1, 0).Activate
          End If
          i = i + 1
      Next trObj
  Next tbObj
  </code></pre>
  
  <p>But this code goes error every time and it said "Run-time error '438': Object doesn't support this property or method" at the line <code>dataArray(i, j) = imgObj.getAttribute("title")</code>. Could some one help me?</p>