少し問題があります。ファイルを解析し、結果を Web バナーに入力する必要があります。問題は、ファイルの名前は「_banner_products.php」で、その内容は次のとおりです。
<?php header('Content-Type:text/xml'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<carouselle>
<firstLayer>
<layerName>Leica Disto X310</layerName>
<layerProduct>Disto X310</layerProduct>
<layerPic>http://www.leicaestonia.ee/extensions/boxes_design/flashpics/1334482548.jpg</layerPic>
<layerPrice>0,-</layerPrice>
<layerPriceOld></layerPriceOld>
<layerLink>http://www.leicaestonia.ee/index.php?id=11627</layerLink>
<layerTimer>01.05.2012 00:00</layerTimer>
</firstLayer>
<firstLayer>
.....
.....
</firstLayer>
</carouselle>
このファイルをループして、すべての「firstLayer」の子を1つにグループ化するにはどうすればよいですか..単に使用する場合:
$file = fopen("_banner_products.php", "r");
while (!feof($file)){
$line = fgets($file);
}
simplexml_load_file はこれをスローします-「_banner_products.php:1: パーサー エラー: 開始タグが必要です、'<'」
次に、 <...> タグの内容のみを取得します。つまり、既に範囲外にあるかどうかを区別する方法はありません。
どなたかご回答いただきありがとうございます。不明な点がある場合は、さらに説明します。
編集。解決策をありがとう、実際に完全な URL を使用するとうまくいきました:
simplexml_load_file("http://localhost/MySite/_banner_products.php");