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 failed:没有这样的主机。在第25行的D:\ xampp \ htdocs \ sweet \ restRendering.php
警告:DOMDocument :: load(http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query=10591):无法打开流:php_network_getaddresses:getaddrinfo failed :没有这样的主人知道。在第25行的D:\ xampp \ htdocs \ sweet \ restRendering.php
警告:DOMDocument :: load():I / O警告:无法加载外部实体“http://www.myweather2.com/developer/forecast.ashx?uac=AnwWoM6K2.&output=xml&query在第25行的D:\ xampp \ htdocs \ sweet \ restRendering.php中= 10591“
答案 0 :(得分:1)
根据这个错误:
警告:DOMDocument :: load():php_network_getaddresses:getaddrinfo failed:没有这样的主机。在第25行的D:\ xampp \ htdocs \ sweet \ restRendering.php
您的服务器存在DNS问题。它无法连接到www.myweather2.com
,因为它无法将其转换为IP地址。
尝试
nslookup www.myweather2.com
并查看结果。当您解决该问题时,您的脚本可能会有效。