2012-09-04 41 views
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. 

} 

在执行我收到此错误:PHP:DOM文档::负载():I/O警告:未能加载外部实体

Warning: DOMDocument::load(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\sweet\restRendering.php on line 25

Warning: DOMDocument::load(http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\sweet\restRendering.php on line 25

Warning: DOMDocument::load(): I/O warning : failed to load external entity "http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591" in D:\xampp\htdocs\sweet\restRendering.php on line 25

+1

可能dublicate:http://stackoverflow.com/questions/9112482/warning-domdocumentload-domdocument-load-io-warning-failed-to-load-ex – Peon

+0

@DainisAbols不提供链接的重复 - 这一个必须做远程URL –

+0

@IvanHušnjak好吧,它是一个重复的情况下的实体错误。这不是DNS问题的一个骗局。 – Gordon

回答

1

根据此错误:

Warning: DOMDocument::load(): php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampp\htdocs\sweet\restRendering.php on line 25

你的服务器有DNS问题。它无法连接到www.myweather2.com,因为它无法将其转换为IP地址。

尝试

nslookup www.myweather2.com 

和看到的结果是什么。当你解决这个问题时,你的脚本可能会工作。

相关问题