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
可能dublicate:http://stackoverflow.com/questions/9112482/warning-domdocumentload-domdocument-load-io-warning-failed-to-load-ex – Peon
@DainisAbols不提供链接的重复 - 这一个必须做远程URL –
@IvanHušnjak好吧,它是一个重复的情况下的实体错误。这不是DNS问题的一个骗局。 – Gordon