title: how to read xml file from url using php
body: <p>I have to read an XML file from an URL</p>
  
  <pre><code>$map_url = "http://maps.google.com/maps/api/directions/xml?origin=".$merchant_address_url."&amp;destination=".$customer_address_url."&amp;sensor=false";
  </code></pre>
  
  <p>This gives me an URL like:</p>
  
  <blockquote>
    <p><a href="http://maps.google.com/maps/api/directions/xml?origin=Quentin+Road+Brooklyn%2C+New+York%2C+11234+United+States&amp;destination=550+Madison+Avenue+New+York%2C+New+York%2C+10001+United+States&amp;sensor=false" rel="noreferrer">http://maps.google.com/maps/api/directions/xml?origin=Quentin+Road+Brooklyn%2C+New+York%2C+11234+United+States&amp;destination=550+Madison+Avenue+New+York%2C+New+York%2C+10001+United+States&amp;sensor=false</a></p>
  </blockquote>
  
  <p>I am using this function to read and then get data:</p>
  
  <pre><code> $response_xml_data = file_get_contents($map_url);
   if($response_xml_data){
       echo "read";
   }
  
   $data = simplexml_load_string($response_xml_data);
   echo "&lt;pre&gt;"; print_r($data); exit; 
  </code></pre>
  
  <p>But no luck, any help?</p>