Link to home
Create AccountLog in
Avatar of TedMorey
TedMoreyFlag for United Kingdom of Great Britain and Northern Ireland

asked on


I was wondering if someone would be able to convert the code below from classic ASP to PHP

    url = "
    set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP") "GET", url, false
    xmlhttp.send "" 

      set xDoc=xmlhttp.responseXML
set  ForecastNode=xDoc.selectSingleNode("MetarGetCurrentConditionsForWeatherStationResponse/MetarReport")
' this should give you the first EveningForecastNode.

temp3 = ForecastNode.getAttribute("Temperature")
temp3_c = (temp3-32)/1.8
'response.write "<li>High Celcius=" & ForecastNode.getAttribute("TemperatureHighCelcius")

    set xmlhttp = nothing
Avatar of haloexpertsexchange
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
all variables start with $ and each statement is ended with a ;
also on line 7 I forgot the $ infront of xDoc.
How is this?

 $url = ""; 
    set $xmlhttp = CreateObject("MSXML2.ServerXMLHTTP"); 
    $xmlhttp.$open "GET", $url, false; 
    $xmlhttp.$send ""; 
      set $xDoc=$xmlhttp.$responseXML;
set  $ForecastNode=$xDoc.$selectSingleNode["MetarGetCurrentConditionsForWeatherStationResponse/MetarReport"];
// this should give you the first EveningForecastNode.
$temp3 = $ForecastNode.$getAttribute["Temperature"];
$temp3_c = ($temp3-32)/1.8;
//response.write "<li>High Celcius=" & ForecastNode.getAttribute("TemperatureHighCelcius")
    set $xmlhttp = nothing; 
 echo round($temp3_c,0); 

Open in new window

I got it from this link and I have often used it and gotten accurate results - not all the time I might add.

Free registration is required to be able to use the tool.

Avatar of Beverley Portlock
From your code I would be looking to use either a SOAP client or SimpleXML

So you could try (UNTESTED)


$xml = simplexml_load_file("");

// Test to see what came back
echo "<pre>";
echo "</pre>";

Open in new window

and then process with the SimpleXML functions