Jump to content

using curl var in dom load


beermaker74

Recommended Posts

ok i have a query to the google base and i am using curl to get the response. ok if i have dom load (something.xml) it works fine. but if i try and put the var from curl in there it breaks. says itis empty in my error. what do i need to do to load it in the dom so i can parse it? thanks

 

$url ='http://google.com/base/feeds/snippets/-/housing?bq=rental+%5blocation:@%22athens,AL%22%2b50mi%5d&max-results=6';
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($c);
curl_close($c);
  $dom = new DomDocument;
  $dom->load("$response");

  foreach ($dom->documentElement->childNodes as $books) {
     if (($books->nodeType == 1) && ($books->nodeName == "entry")) {

          foreach ($books->childNodes  as $theBook) {
              if (($theBook->nodeType == 1) &&
            ($theBook->nodeName == "id")) {
                 $id = $theBook->textContent;
            }

		if (($theBook->nodeType == 1) &&
             ($theBook->nodeName == "published")) {
                 $published = $theBook->textContent;
             }

Link to comment
https://forums.phpfreaks.com/topic/40496-using-curl-var-in-dom-load/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.