次のような XML があります。
<item code="1">
<description>This is an item.</description>
<prices>
<price nett="1.50"/>
<price code="RPP" nett="20.33" />
</prices>
</item>
そして、次のようにPHPを使用してDBにインポートしようとしています:
$xmlurl = 'thexmlfile.xml';
$dom = new DOMDocument();
$dom->load($xmlurl);
$records = $dom->getElementsByTagName('item');
foreach($records as $record) {
$descs = $record-> getElementsByTagName('description');
$desc = $descs->item(0)->nodeValue;
echo $desc . '<br />';
}
それはうまくいきます。説明を引っ張る。しかし、商品コードと価格セクションを取得するにはどうすればよいですか? ループ内ループ?]
ありがとうございました