我使用下面的代碼...錯誤在讀取XML文件
//定義我們想寫信給我們希望從
$filename = 'capital_one.xml';
$url = "http://feeds.perfb.com/index.php/[email protected]&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;
}
下載的文件名和URL我得到了以下錯誤
開捕致命錯誤:參數1傳遞給的DOMNode ::使用appendChild()必須的DOMNode
的實例你能幫幫我嗎?
你需要自己做一些調查,並告訴我們你的發現。錯誤發生在哪條線上?通過搜索錯誤消息文本找到了什麼?您是否閱讀過模塊的錯誤處理設施? – 2012-04-18 05:54:35