troubleshooting Question

Curl php script to grab nodes fails

Avatar of rhandalthor
rhandalthorFlag for Russian Federation asked on
PHPWeb DevelopmentApache Web Server
6 Comments3 Solutions520 ViewsLast Modified:
Following cURL Xpath script found on web - - I want to use as a base for grabbing H1s fails with undefined variable on line 30. Why?
function get_url($url)
     $curl = curl_init();
     curl_setopt($curl, CURLOPT_HEADER, 0);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_URL, $url);
     $data = curl_exec($curl);
     return $data;

function get_url_data()
     $xml_content = get_url("");
     $dom = new DOMDocument();
     $xpath = new DomXPath($dom);
     $content_title = $xpath->query('//channel//title/text()');
     return $content_title;

function print_url_data()
     $content = get_url_data();
     foreach ($content as $value)
          $output .= $value->nodeValue . "<br />";
     return $output;

echo print_url_data();

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros