-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()が を返さない場合DOMNode、エラーが発生し、FALSE代わりに が返されます。

于 2012-04-18T06:11:49.390 に答える