title: Trapping Object required: '[object]' with MSXML2.ServerXMLHTTP.6.0
body: <p>I am using the Flickr API and MSXML2.ServerXMLHTTP.6.0 to read the XML response.</p>
  
  <p>For example:</p>
  
  <p><a href="https://www.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=[mykey]&amp;text=cheese&amp;per_page=1&amp;sort=relevance&amp;min_upload_date=2010-05-25" rel="nofollow">https://www.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=[mykey]&amp;text=cheese&amp;per_page=1&amp;sort=relevance&amp;min_upload_date=2010-05-25</a></p>
  
  <p>Returns:</p>
  
  <pre><code>&lt;rsp stat="ok"&gt;
      &lt;photos page="1" pages="847622" perpage="1" total="847622"&gt;
          &lt;photo id="8658999887" owner="46248160@N04" secret="13e2615193" server="8123" farm="9" title="cheeses" ispublic="1" isfriend="0" isfamily="0"/&gt;
      &lt;/photos&gt;
  &lt;/rsp&gt;
  </code></pre>
  
  <p>I do some simple ASP to set variable values:</p>
  
  <pre><code>vurl = https://www.flickr.com/services/rest/?method=flickr.photos.search&amp;api_key=[mykey]&amp;text=cheese&amp;per_page=1&amp;sort=relevance&amp;min_upload_date=2010-05-25
  Set http = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
  http.Open "GET", vurl, False
  http.Send
  
  Set dom = http.responseXML
  
  Set items = dom.getElementsByTagName("photos")
  
  If NOT (items IS Nothing) Then
  
      For Each item In items
  
          Set tags = item.getElementsByTagName("photo")
          If NOT (tags IS Nothing) Then 
              var_id = tags(0).getAttribute("id")
              var_owner = tags(0).getAttribute("owner")
              var_server = tags(0).getAttribute("server")
              var_farm = tags(0).getAttribute("farm")
              var_title = tags(0).getAttribute("title")
              var_public = tags(0).getAttribute("public")
              var_secret = tags(0).getAttribute("secret")
              var_img_url2 = "https://farm"&amp;var_farm&amp;".staticflickr.com/"&amp;var_server&amp;"/"&amp;var_id&amp;"_"&amp;var_secret&amp;"_b.jpg"
              var_id = ""
              %&gt;
              &lt;%
          End If
  
      Next
  
  end if
  </code></pre>
  
  <p>My problem is that if there is no image returned by the API for a search term - e.g. "aplogranite" the XML response is:</p>
  
  <pre><code>&lt;rsp stat="ok"&gt;
      &lt;photos page="1" pages="0" perpage="1" total="0"/&gt;
  &lt;/rsp&gt;
  </code></pre>
  
  <p>My code above returns this error:</p>
  
  <pre><code>Microsoft VBScript runtime error '800a01a8'
  
  Object required: '[object]' 
  </code></pre>
  
  <p>I tried trapping it via:</p>
  
  <pre><code>Set items = dom.getElementsByTagName("photos")
  
  If NOT (items IS Nothing) Then...
  </code></pre>
  
  <p>But it still errors.</p>
  
  <p>I wondered how I could trap the error so that I can handle the scenario where the XML does not contain any data within the "photo" tag?</p>