How to parse feed with php

Weikert

New Member
Using Wikiepdia API link to get some basic informations about some world known characters.Example : (About Dave Longaberger)This would show as following
MCg07.png
Now my questionI'd like to parse the xml to get such basic informations between \[code\]<extract></extract>\[/code\] to show it.Here is my idea but failed (I/O warning : failed to load external entity)\[code\]<?PHP$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Dave Longaberger&format=xml&exintro=1';$xml = simplexml_load_file($url);// get extract$text=$xml->pages[0]->extract;// show titleecho $text;?>\[/code\]Another idea but also failed (failed to open stream: HTTP request failed!)\[code\]<?PHPfunction get_url_contents($url){$crl = curl_init();$timeout = 5;curl_setopt ($crl, CURLOPT_URL,$url);curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);$ret = curl_exec($crl);curl_close($crl);return $ret;}$url = "http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Dave Longaberger&format=xml&exintro=1";$text = file_get_contents($url);echo $text;?>\[/code\]so any idea how to do it. ~ ThanksUpdate (after added urlencode or rawurlencode still not working)\[code\]$name = "Dave Longaberger";$name = urlencode($name);$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles='.$name.'&format=xml&exintro=1';$text = file_get_contents($url);\[/code\]Also not working\[code\]$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles=Dave Longaberger&format=xml&exintro=1';$url = urlencode($url);$text = file_get_contents($url);\[/code\]nor\[code\]$url = 'http://en.wikipedia.org/w/api.php?action=query&prop=extracts&titles='.rawurlencode('Dave Longaberger').'&format=xml&exintro=1';$text = file_get_contents($url);\[/code\]Well so i really don't know looks like it is impossible by somehow.
 
Back
Top