1

xml ファイル ( Web フォームで作成されたもの) を php ページに読み込もうとしています。製品が追加されるとディレクトリが作成され、後でページによってコールバックされる各製品の XML が書き込まれます。

これは私が得るエラーです。

警告: DOMDocument::load() [domdocument.load]: エンティティ 'nbsp' が /home/content/41/11699441/html/nc/products/belly-dump/234efg/data.xml で定義されていません。行: 4 インチ/home/content/41/11699441/html/nc/includes/_xml.php の 4 行目

XML 読み込みコードは次のとおりです。

  1. $xmlDoc = 新しい DOMDocument();
  2. $xmlDoc->load('data.xml');

XML ファイル:

<?xml version="1.0"?>
<xml>
<model>
    <type>Gravel Box</type>
    <titleXML>345FGH - Tridem Clamshell</titleXML>
    <features>here are features</features>
    <options>here are options</options>
    <gallery>my photo gallery directory</gallery>
    <info>additional information</info>
</model>
</xml>

XML Doc を作成する PHP コード

`$xml = new SimpleXMLElement('');

$model = $xml->addChild('model');
$model->addChild('type', $type);
$model->addChild('titleXML', $titleXML);
$model->addChild('features', $feature);
$model->addChild('options', $option);
$model->addChild('gallery', $gallery);
$model->addChild('info', $info);

$xml->saveXML($target_Path.'data.xml');`

4

1 に答える 1