I'm trying to get all the URL's to return from the XML file, but its not working you can view my code below. What am I doing wrong? <?php error_reporting(E_ERROR); // The web services request $request = 'http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=IynIbtvV34G.J8x_W3c2xMSUWHuS7YLx32FiqZ_eThniaY0H4cZlsC.rzgzOLw--&query=inurl:.edu&results=100&xargs=0&pstart=1&b=101'; // Fetch it $response = file_get_contents($request); if ($response === false) { die('The request failed'); } // Create a new DOM object $dom = new DOMDocument(); $dom->load($response); // Load the XML into the DOM if ($dom->loadXML($response) === false) { die('Parsing failed'); } $note = $dom->getElementsByTagName("Url"); foreach ($note as $value){ $tasks = $value->getElementsByTagName("url"); echo $tasks; } ?> PHP: I thought tasks would show all the URL's from the Yahoo API search?
google for xmltoarray in php and you will find script which will get you scripts for converting xml file contents to array .. then you can easily code your self with the array sample script http://www.codewalkers.com/c/a/Database-Code/Improved-XML-To-Array/
hi there, the code above is the working one <?php error_reporting(E_ERROR);// The web services request $request = 'http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=IynIbtvV34G.J8x_W3c2xMSUWHuS7YLx32FiqZ_eThniaY0H4cZlsC.rzgzOLw--&query=inurl:.edu&results=100&xargs=0&pstart=1&b=101'; // Fetch it $response = file_get_contents($request); if ($response === false) { die('The request failed'); } // Create a new DOM object $dom = new DOMDocument(); $dom->load($response); // Load the XML into the DOM if ($dom->loadXML($response) === false) { die('Parsing failed'); } $note = $dom->getElementsByTagName("Result"); foreach ($note as $value){ $tasks = $value->getElementsByTagName("Url")->item(0)->nodeValue; echo 'URL: ' .$tasks. '<br />'; } ?> PHP: