Only proceed to read XML if variable has certain value
<p>I have a rather simple piece of PHP code</p>

<pre><code>$xml = file_get_contents($url, false, $context);
$response = simplexml_load_string($xml);
$status_response = $response-&gt;xpath('/PollSessionResponseDto/Status');
$answer = $status_response[0];

while ($answer&lt;&gt;"UpdatesComplete") {
    sleep(2);
    $answer = $response-&gt;xpath('/PollSessionResponseDto/Status')[0];
} 

$itenaries = $response-&gt;xpath('/PollSessionResponseDto/Itineraries/ItineraryApiDto');
</code></pre>

<p>I am <a href="http://partners.api.skyscanner.net/apiservices/pricing/hk1/v1.0/645b3e893bed4404856a8dad8a1193c2_ecilpojl_B0B79BD58EA0D3CB97FB0E3930838587?apiKey=di712416621208689877979118676073&amp;stops=0" rel="nofollow">reading an XML file, for example</a>, and I only want to proceed to read the itenaries if status in the XML file is "UpdatesComplete". If status is "UpdatesPending", I basically want to wait 2 seconds. Then check again and wait another 2 seconds if necessary.</p>

<p>However I end up in an infinite loop. I checked my <code>$answer</code> variable and it seems that I am getting the string I want to check (UpdatesPending or UpdatesComplete).</p>

<p>Can anybody tell me what I am doing wrong? </p>