-1

我正在使用以下代码...

//定义我们想要写入的文件名和我们想要下载的url

    $filename = 'capital_one.xml';
    $url = "http://feeds.perfb.com/index.php/download?OEMAIL=chirag_gir@visitwembley.co.uk&PX=e90daba5ee2c6fd4d0c344fd61911f33&DISPLAYFORMAT=HEAD&REVERSEMAPXML=yes&PRODUCTDB_ID=294";



 //this creates the file "feed download".xml and takes he contents from the URL and stores them into the file
file_put_contents($filename,file_get_contents($url));

//create instance of XMLReader
    $xmlReader = new XMLReader();

//read in xml file
$xmlReader->open($filename);

//loop to read in data
while($xmlReader->read())
{
         //this initialises the xml parser
         $dom = new DOMDocument();
         $domNode = $xmlReader->expand();
         $element = $dom->appendChild($domNode);
         $domString = utf8_encode($dom->saveXML($element));
         $product = new SimpleXMLElement($domString);

         //read in data
         echo $product_code = $product->product_code;


}

我收到以下错误

可捕获的致命错误:传递给 DOMNode::appendChild() 的参数 1 必须是 DOMNode 的实例

你能帮我么 ?

4

1 回答 1

1

如果expand()不返回 a DOMNode,则发生错误并FALSE返回。

于 2012-04-18T06:11:49.390 回答