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: 没有这样的主机是已知的。在 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