PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
supasilvio
Forum Newbie
Posts: 2 Joined: Sun May 02, 2010 3:36 pm
Post
by supasilvio » Sun May 02, 2010 3:41 pm
Hello, I'm trying to get the .xml I get from this page:
http://google.com/complete/search?outpu ... =microsoft
and print it to an html using this code:
Code: Select all
<?php
$xml = simplexml_load_file('http://google.com/complete/search?output=toolbar&q=microsoft');
foreach($xml->CompleteSuggestion as $CompleteSuggestion)
{
echo '<p> '.$CompleteSuggestion->suggestion['data'].' </p>';
}
?>
When the .xml is an existing file the code works, but when I use the link the page is blank....
thank you for helping
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sun May 02, 2010 3:54 pm
Are you getting any errors or notices? What about trying to load the xml as a string. I.e.,
Code: Select all
$content = file_get_contents('http://google.com/complete/search?output=toolbar&q=microsoft');
$xml = simplexml_load_string($content);
supasilvio
Forum Newbie
Posts: 2 Joined: Sun May 02, 2010 3:36 pm
Post
by supasilvio » Sun May 02, 2010 4:02 pm
No errors or notices, just a blank page (even the source)....
I tried with your code but nothing changes
thanks anyway
requinix
Spammer :|
Posts: 6617 Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA
Post
by requinix » Sun May 02, 2010 7:03 pm
Your original code works fine for me.
Turn up error_reporting to E_ALL and enable display_errors.