我正在使用以下代码......
//定义我们希望写入的文件名以及我们希望从
下载的网址 $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的实例
你能帮我吗?答案 0 :(得分:1)
如果expand()
未返回DOMNode
,则会发生错误,而是返回FALSE
。