使用すると{{$node[0]->url}}
、Laravel のテンプレート エンジンは正しい結果を表示しますが、@for $i=0 を @foreach ループ内で使用してすべてを表示する方法がわかりません。これは、ルート ファイルにあるものです。
$oReturn = new stdClass();
$fid='endpoints';//sample fid
$url = 'http://localhost:5493/sdata/$system/registry/'.$fid;
$xml = simplexml_load_file($url);
foreach($xml->xpath("//sdata:payload") as $entry) {
// xpath here must be from payload to endPoint--type
$content = $entry->xpath("./sdata:endPoint--type");
foreach($content as $c) {
// Make set of children with prefix sdata
$nodes = $c->children('sdata', true);
}
// add parsed data to the array
$oReturn->entry[] = $nodes;
}
return View::make('index', compact('oReturn'));
これは、ビューファイルで試したものです
@for($i=0; $i < 4; $i++)
@endfor
@foreach ($oReturn as $node)
<li>{{$node[$i]->url}}</li>
@endforeach
申し訳ありませんが、完全な print_r 結果はこちらです
Array ( [oReturn] => stdClass Object
( [entry] => Array
(
[0] => SimpleXMLElement Object ( [description] => Sage 50 Accounts [protocol] => http [host] => base_3 [applicationName] => accounts50 [contractName] => SimpleXMLElement Object ( ) [dataSetName] => - [url] => http://base_3:5493/sdata/accounts50 [isBrowsable] => true [aliveStamp] => 2015-11-06T23:31:10.031+00:00 )
[1] => SimpleXMLElement Object ( [endPointType] => dataSet [applicationName] => accounts50 [contractName] => GCRM [dataSetName] => Enter Your Company Name [url] => http://base_3:5493/sdata/accounts50/GCRM/{C22ACA13-3C4C-4E33-A584-CD99BD3002A6} )
[2] => SimpleXMLElement Object ( [endPointType] => dataSet [applicationName] => accounts50 [contractName] => GCRM [dataSetName] => Enter Your Company Name [url] => http://base_3:5493/sdata/accounts50/GCRM/{FF476636-D4AF-4191-BDE4-891EDA349A68} )
[3] => SimpleXMLElement Object ( [endPointType] => dataSet [applicationName] => accounts50 [contractName] => GCRM [dataSetName] => Enter Your Company Name [url] => http://base_3:5493/sdata/accounts50/GCRM/{C62A13D5-3FFE-43B4-9DAF-38F9055A83C7} )
[4] => SimpleXMLElement Object ( [description] => GCRM Contract [endPointType] => contract [protocol] => http [host] => base_3 [applicationName] => accounts50 [contractName] => GCRM [dataSetName] => - [url] => http://base_3:5493/sdata/accounts50/GCRM [aliveStamp] => 2015-11-06T23:31:11.062+00:00 )
)
)
) 1