title: cURL Page and Navigate DOM
body: <p>I am simply trying to retrieve a pages' title with the script below. However, I am doing something wrong because I keep getting this error:</p>
  
  <pre><code>PHP Fatal error:  Call to a member function getElementsByTagName() on a non-object in /Users/robertquinn/Desktop/SCRAPE/asu.php on line 22  
  </code></pre>
  
  <p>This is my first time using curl functions so please let me know if I am horribly screwing something up here. is getElementsByTagName() soley an XML DOM method?</p>
  
  <pre><code>&lt;?php  
  
      function get_data($url) {
  
          $userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5';
          $ch = curl_init();
          curl_setopt($ch,CURLOPT_COOKIE,"someCookie=2127;onlineSelection=C");
          curl_setopt ($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
          curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
          curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
          curl_setopt($ch, CURLOPT_URL, $url);
          curl_setopt($ch, CURLOPT_FAILONERROR, true);
          curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
          curl_setopt($ch, CURLOPT_AUTOREFERER, true);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
          curl_setopt($ch, CURLOPT_TIMEOUT, 100);
          $html = curl_exec($ch);
          curl_close($ch);
  
          $doc = new DOMDocument();
          $body = $doc-&gt;loadHTML( $html );
          $title_value = $body-&gt;getElementsByTagName('title')-&gt;nodeValue;
  
          echo $title_value;
      }
  
      get_data('http://www.someurl.com');
  
      ?&gt;
  </code></pre>