title: How to parse image feed with php
body: <p>Using Wikipedia API link to get main image about some world known characters/events.</p>
  
  <p>Example : (<a href="http://en.wikipedia.org/w/api.php?action=query&amp;list=allimages&amp;aiprop=url&amp;format=xml&amp;ailimit=1&amp;aifrom=Stanislao%20Mattei" rel="nofollow noreferrer">Stanislao Mattei</a>)</p>
  
  <p>This would show as following
  <img src="https://i.stack.imgur.com/wi24B.png" alt="Wikipedia API Stanislao Mattei"></p>
  
  <p><strong>Now my question</strong> 
  I'd like to parse the xml to get image url to be shown up</p>
  
  <p>here is the code i'm willing to use if it right ~ thanks to <a href="https://stackoverflow.com/users/1179287/cckep">ccKep</a> ~</p>
  
  <pre><code>&lt;?PHP
  ini_set("user_agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
  
  $url = "http://en.wikipedia.org/w/api.php?action=query&amp;list=allimages&amp;aiprop=url&amp;format=xml&amp;ailimit=1&amp;aifrom=Stanislao Mattei";
  
  $xml = simplexml_load_file($url);
  
  $extracts = $xml-&gt;xpath("/api/query/allimages");
  
  var_dump($extracts);
  ?&gt;
  </code></pre>
  
  <p>It should gives results as array</p>
  
  <p>how i can get among it the exact url of the image to be shown  should be : </p>
  
  <pre><code>http://upload.wikimedia.org/wikipedia/en/a/a1/Stanislaus.jpg
  </code></pre>
  
  <p>to put it in html code</p>
  
  <pre><code>&lt;img src="http://upload.wikimedia.org/wikipedia/en/a/a1/Stanislaus.jpg"&gt;
  </code></pre>
  
  <p>~ Thanks a lot</p>