We help IT Professionals succeed at work.
Get Started

Curl php script to grab nodes fails

518 Views
Last Modified: 2012-05-11
Following cURL Xpath script found on web -http://www.devdevote.com/server-script/php/get-xml-data-with-xpath-curl - I want to use as a base for grabbing H1s fails with undefined variable on line 30. Why?
<?php
function get_url($url)
{a
     $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);
     curl_close($curl);
     return $data;
}

function get_url_data()
{
     $xml_content = get_url("http://wordpress.org/development/feed/");
     $dom = new DOMDocument();
     @$dom->loadXML($xml_content);
     $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

Comment
Watch Question
This problem has been solved!
Unlock 3 Answers and 6 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE