XMLストリームがSimpleXMLElementオブジェクトに解析されていますが、使用可能なレコードをPHPページの値として繰り返し処理しようとしています。SimpleXMLElementオブジェクトであるXML値を反復処理する方法
[リスト]の親ノードは、テストXML([0]とリスト[1]のリスト)の2つのレコードと同じ2倍です。 しかし、私はこれを "Basic SimpleXML PHPマニュアル
<?php
$xml = simplexml_load_file('http://feed.postlets.com/Burndog/6458ec1af54f632');
から用法」これは最初のリストのタイトル要素の値を提供するために動作します:
$value1 = $xml->listing[0]->title;
echo ' here:' . $value1;
これは、利用可能な値を反復処理するために失敗します。
しますprint_rからのforeach ($xml->listing->title as $title) {
echo $title;
}
?>
値:1以上があるよう
SimpleXMLElement Object
(
[listing] => Array
(
[0] => SimpleXMLElement Object
(
[url] => http://www.postlets.com/repb/6509636
[title] => 3BR/2BA Manufactured - Beaumont
[subtitle] => SimpleXMLElement Object
(
)
[description] => SimpleXMLElement Object
(
)
[location] => SimpleXMLElement Object
(
[street] => 1415 E 6th St
[city] => Beaumont
[zipcode] => 92223
[state] => CA
[latitude] => 33.928326
[longitude] => -116.959923
[walkscore] => 46
)
[details] => SimpleXMLElement Object
(
[money] => SimpleXMLElement Object
(
[price] => 44900
)
[property_for] => Sale
[property_use] => Residential
[property_type] => Manufactured
[year_built] => 2011
[bedrooms] => 3
[full_bathrooms] => 2
[partial_bathrooms] => 0
[sqft] => 1041
[lot_size] => 1045 sqft
[parking] => SimpleXMLElement Object
(
)
)
[photos] => SimpleXMLElement Object
(
[photo_1] => http://www.postlets.com/create/photos/20111101/082821_6509636_158803034.jpg
[photo_caption_1] => Photo 1
[photo_2] => http://www.postlets.com/create/photos/20111101/082822_6509636_3416721218.jpg
[photo_caption_2] => Photo 2
[photo_3] => http://www.postlets.com/create/photos/20111101/082822_6509636_1298858591.jpg
[photo_caption_3] => Photo 3
)
[contact] => SimpleXMLElement Object
(
)
)
[1] => SimpleXMLElement Object
(
[url] => http://www.postlets.com/repb/7066849
[title] => 2BR/1+1BA Manufactured - Beaumont
[subtitle] => SimpleXMLElement Object
(
)
[description] => SimpleXMLElement Object
(
)
[location] => SimpleXMLElement Object
(
[street] => 1415 E 6th St # 12
[city] => Beaumont
[zipcode] => 92223
[state] => CA
[latitude] => 33.929199
[longitude] => -116.959831
[walkscore] => 46
)
[details] => SimpleXMLElement Object
(
[money] => SimpleXMLElement Object
(
[price] => 56000
[hoa] => 400
)
[property_for] => Sale
[property_use] => Residential
[property_type] => Manufactured
[year_built] => 1997
[bedrooms] => 2
[full_bathrooms] => 1
[partial_bathrooms] => 1
[sqft] => 1250
[lot_size] => 3000 sqft
[property_features] => Central A/C, Dining room, Breakfast nook, Dryer
[community_features] => Covered parking
[parking] => SimpleXMLElement Object
(
)
) etc etc
は、その後、それは絵のための要素をループに何を取るのだろうか? ありがとう!
:HTTPあなたはこのような何かをしたい
て写真を印刷するには:だからあなたは何をすべきかのリストを反復処理し、各リストのタイトルをプリントアウトです。あなたの最初のforeachは完璧に動作//stackoverflow.com/q/871422/351893 – JochenJung