1
class restRendering
{
    public $RestUrl='http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591';
    public $XSLTPath="receipe.xsl";

    //setter method for test url

        public function setRestUrl( $value )  
        {  
            $this->RestUrl = $value;  
        }  
        public function setXSLTPath( $value ) 
        {
            $this->XSLTPath = $value;  
        }

        //It renders the iframe with base url and path.
        public function render(){
             //load the XML 
                  $xml_Doc = new DOMDocument();

                  if($xml_Doc->load($this->RestUrl))
                  {
                          //load the XSL 
                          $xsl= new DOMDocument();
                          $xsl->load($this->XSLTPath) or die("can not load  XSLT file"); 

                         $xslt = new XSLTProcessor($xsl);
                         $xslt->importStyleSheet($xsl);

                            print $xslt->transformToXML( $xml_Doc ) or die("Trasform Error");
                    }
                else{
                        echo "Can not load the url";
                    } 


        }   //End of Render method.

}

実行中にこのエラーが発生します:

警告:DOMDocument :: load():php_network_getaddresses:getaddrinfoが失敗しました:そのようなホストは不明です。D:\ xampp \ htdocs \ sweet \restRendering.phpの25行目

警告:DOMDocument :: load(http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591):ストリームを開くことができませんでした:php_network_getaddresses:getaddrinfoに失敗しました:そのようなホストは不明です。D:\ xampp \ htdocs \ sweet \restRendering.phpの25行目

警告:DOMDocument :: load():I / O警告:D:\の外部エンティティ"http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591"の読み込みに失敗しました25行目のxampp\htdocs \ sweet \ restRendering.php

4

1 に答える 1

1

このエラーによると:

警告:DOMDocument :: load():php_network_getaddresses:getaddrinfoが失敗しました:そのようなホストは不明です。D:\ xampp \ htdocs \ sweet \restRendering.phpの25行目

サーバーにDNSの問題があります。www.myweather2.comIPアドレスに変換できないため、接続できません。

試す

nslookup www.myweather2.com

結果がどうなるかを見てください。その問題を解決すると、スクリプトはおそらく機能します。

于 2012-09-04T09:01:32.427 に答える