xml load error?
Posted: Thu Feb 25, 2010 8:58 pm
I'm new to PHP, and am trying to implement a basic PHP code to read from two xml files;
http://weather.aero/dataserver_current/ ... urrent.xml
http://weather.aero/dataserver_current/ ... urrent.xml
I'm selectively pulling data from the xml files to be displayed on the webpage. I've been able to get the code to run locally on my machine using Wampserver, however, when I try to run it from the web it doesn't seem to fully "run". Here is the code;
With regards to it "not fully running". It will usually load the METAR data, and sometimes the TAF data. Also there are some other images on the pages that should also be displayed, but they are not displaying. I've tried to make sense of the error logs, but from what I see it seems like the METAR shouldn't display either. Here is a sample from the error log;
As you might notice from the code above (see commented line) I've been trying to dig around on the web to see what "fixes" I can find. I'm not sure if it's code related or server (settings?) related? My hunch is it's server related as, like I mentioned, it will run locally on my machine fine using Wampserver.
Any help would be GREATLY appreciated!
http://weather.aero/dataserver_current/ ... urrent.xml
http://weather.aero/dataserver_current/ ... urrent.xml
I'm selectively pulling data from the xml files to be displayed on the webpage. I've been able to get the code to run locally on my machine using Wampserver, however, when I try to run it from the web it doesn't seem to fully "run". Here is the code;
Code: Select all
<h1>METAR:</h1>
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->preserveWhiteSpace = FALSE;
$xmlDoc->load( "http://weather.aero/dataserver_current/current/metars.current.xml", LIBXML_DTDLOAD|LIBXML_DTDATTR );
// $xmlDoc = DOMDocument::load( "http://weather.aero/dataserver_current/current/metars.current.xml", LIBXML_DTDLOAD|LIBXML_DTDATTR );
$METAR_stations = $xmlDoc->getElementsByTagName( "METAR" );
foreach( $METAR_stations as $METAR_station )
{
$METAR_reports = $METAR_station->getElementsByTagName( "station_id" );
$METAR_report = $METAR_reports->item(0)->nodeValue;
$METAR_texts = $METAR_station->getElementsByTagName( "raw_text" );
$METAR_text_report = $METAR_texts->item(0)->nodeValue;
if ($METAR_report == "KDLH"){
echo "<H2>$METAR_text_report</H2>\n";
}
}
?>
<br />
<br />
<h1>TAF:</h1>
<?php
$xmlDoc = new DOMDocument();
$xmlDoc->preserveWhiteSpace = FALSE;
$xmlDoc->load( "http://weather.aero/dataserver_current/current/tafs.current.xml", LIBXML_DTDLOAD|LIBXML_DTDATTR );
// $xmlDoc = DOMDocument::load( "http://weather.aero/dataserver_current/current/tafs.current.xml", LIBXML_DTDLOAD|LIBXML_DTDATTR );
$TAF_stations = $xmlDoc->getElementsByTagName( "TAF" );
foreach( $TAF_stations as $TAF_station )
{
$TAF_reports = $TAF_station->getElementsByTagName( "station_id" );
$TAF_report = $TAF_reports->item(0)->nodeValue;
$TAF_texts = $TAF_station->getElementsByTagName( "raw_text" );
$TAF_text_report = $TAF_texts->item(0)->nodeValue;
if ($TAF_report == "KDLH"){
echo "<H2>$TAF_text_report\n</H2>";
}
}
?>
With regards to it "not fully running". It will usually load the METAR data, and sometimes the TAF data. Also there are some other images on the pages that should also be displayed, but they are not displaying. I've tried to make sense of the error logs, but from what I see it seems like the METAR shouldn't display either. Here is a sample from the error log;
- PHP Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://weather.aero/dataserver_current/ ... urrent.xml" in /hermes/bosweb/web102/b1025/ipw.handsomedave/public_html/FlightTestWX/index.php on line 42
PHP Warning: DOMDocument::load() [domdocument.load]: URL file-access is disabled in the server configuration in /hermes/bosweb/web102/b1025/ipw.handsomedave/public_html/FlightTestWX/index.php on line 66
PHP Warning: DOMDocument::load(http://weather.aero/dataserver_current/ ... urrent.xml) [domdocument.load]: failed to open stream: no suitable wrapper could be found in /hermes/bosweb/web102/b1025/ipw.handsomedave/public_html/FlightTestWX/index.php on line 66
PHP Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://weather.aero/dataserver_current/ ... urrent.xml" in /hermes/bosweb/web102/b1025/ipw.handsomedave/public_html/FlightTestWX/index.php on line 66
As you might notice from the code above (see commented line) I've been trying to dig around on the web to see what "fixes" I can find. I'm not sure if it's code related or server (settings?) related? My hunch is it's server related as, like I mentioned, it will run locally on my machine fine using Wampserver.
Any help would be GREATLY appreciated!