You are here:  » Very Slow and No results returned


Very Slow and No results returned

Submitted by terencef on Mon, 2008-07-07 18:00 in

Hi; I used the demo to generate my script and when I acces it via the website it takes a long time to complete and the page is blank...

<?php
  require("MagicParser.php");
  $filename = "http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLclient.php?whichClient=NDFDgenMultiZipCode&lat=&lon=&listLatLon=&lat1=&lon1=&lat2=&lon2=&resolutionSub=&listLat1=&listLon1=&listLat2=&listLon2=&resolutionList=&endPoint1Lat=&endPoint1Lon=&endPoint2Lat=&endPoint2Lon=&listEndPoint1Lat=&listEndPoint1Lon=&listEndPoint2Lat=&listEndPoint2Lon=&zipCodeList=28033&listZipCodeList=&centerPointLat=&centerPointLon=&distanceLat=&distanceLon=&resolutionSquare=&listCenterPointLat=&listCenterPointLon=&listDistanceLat=&listDistanceLon=&listResolutionSquare=&citiesLevel=&listCitiesLevel=&sector=&gmlListLatLon=&featureType=&requestedTime=&startTime=&endTime=&compType=&propertyName=&product=time-series&begin=2008-07-07T00%3A00%3A00&end=2008-07-07T21%3A00%3A00&temp=temp";
  function myRecordHandler($record)
  {
    print $record["LOCATION/POINT-LATITUDE"];
    print $record["LOCATION/POINT-LONGITUDE"];
    print $record["TIME-LAYOUT/START-VALID-TIME"];
    print $record["TIME-LAYOUT/START-VALID-TIME@1"];
    print $record["TIME-LAYOUT/START-VALID-TIME@2"];
    print $record["TIME-LAYOUT/START-VALID-TIME@3"];
    print $record["PARAMETERS/TEMPERATURE/NAME"];
    print $record["PARAMETERS/TEMPERATURE/VALUE"];
    print $record["PARAMETERS/TEMPERATURE/VALUE@1"];
    print $record["PARAMETERS/TEMPERATURE/VALUE@2"];
    print $record["PARAMETERS/TEMPERATURE/VALUE@3"];
    }
  MagicParser_parse($filename,"myRecordHandler");
?>

What am I doing wrong?

Thanks

David; I forgot the trialing / in my attempts to use the format option!!

Thanks for correction!

Submitted by support on Mon, 2008-07-07 18:08

Hi,

I just tried the URL in your example, and it loads quickly enough, so I'm wondering
if the speed issue is down to the size of the file, combined with the fact that you
are not using a supplied Format String in the call to MagicParser_parse() - which
means that the parser must try and read the entire file before returning records.

In this case - possibly a function of the latest contents - it is not selecting the
correct record type.

The solution is to provide the format string for the records you want, which based
on the fields used in your example code is:

xml|DWML/DATA/

Try including this by modifying your script as follows:

<?php
  
require("MagicParser.php");
  
$filename "http://www.weather.gov/forecasts/xml/SOAP_server/ndfdXMLclient.php?whichClient=NDFDgenMultiZipCode&lat=&lon=&listLatLon=&lat1=&lon1=&lat2=&lon2=&resolutionSub=&listLat1=&listLon1=&listLat2=&listLon2=&resolutionList=&endPoint1Lat=&endPoint1Lon=&endPoint2Lat=&endPoint2Lon=&listEndPoint1Lat=&listEndPoint1Lon=&listEndPoint2Lat=&listEndPoint2Lon=&zipCodeList=28033&listZipCodeList=&centerPointLat=&centerPointLon=&distanceLat=&distanceLon=&resolutionSquare=&listCenterPointLat=&listCenterPointLon=&listDistanceLat=&listDistanceLon=&listResolutionSquare=&citiesLevel=&listCitiesLevel=&sector=&gmlListLatLon=&featureType=&requestedTime=&startTime=&endTime=&compType=&propertyName=&product=time-series&begin=2008-07-07T00%3A00%3A00&end=2008-07-07T21%3A00%3A00&temp=temp";
  function 
myRecordHandler($record)
  {
    print 
$record["LOCATION/POINT-LATITUDE"];
    print 
$record["LOCATION/POINT-LONGITUDE"];
    print 
$record["TIME-LAYOUT/START-VALID-TIME"];
    print 
$record["TIME-LAYOUT/START-VALID-TIME@1"];
    print 
$record["TIME-LAYOUT/START-VALID-TIME@2"];
    print 
$record["TIME-LAYOUT/START-VALID-TIME@3"];
    print 
$record["PARAMETERS/TEMPERATURE/NAME"];
    print 
$record["PARAMETERS/TEMPERATURE/VALUE"];
    print 
$record["PARAMETERS/TEMPERATURE/VALUE@1"];
    print 
$record["PARAMETERS/TEMPERATURE/VALUE@2"];
    print 
$record["PARAMETERS/TEMPERATURE/VALUE@3"];
  }
  
MagicParser_parse($filename,"myRecordHandler","xml|DWML/DATA/");
?>

Bear in mind that the data will all come out together because there is no formatting
in this script, but as long as you can see the data you can then of course begin
using it to create the output you want or insert into a database etc.

Hope this helps,
Cheers,
David.