读取 XML 文件时出错


Error During Reading XML file

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

定义我们要写入的文件名和我们希望从中下载的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 的参数 1::appendChild() 必须是 DOMNode 的实例

你能帮帮我吗?

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