このような配列があります。SimpleXMLElementオブジェクトをエコーする
Array
(
[@attributes] => Array
(
[version] => 2.0
)
[channel] => SimpleXMLElement Object
(
[title] => Active Fire Incident Page
[link] => http://www.ci.austin.tx.us/fact/default.cfm
[description] => This page provides information on active Austin/Travis County Fire incidents. Data is updated every 3 minutes.
[lastBuildDate] => Wed, 23 Nov 2016 10:59:38 PM GMT
[copyright] => 2016 City of Austin. All rights reserved.
[language] => en-us
[item] => SimpleXMLElement Object
(
[title] => E ST ELMO RD/SHERATON AVE
[link] => http://www.ci.austin.tx.us/fact/default.cfm
[description] => AFD - 4700 S Congress Ave - BOX -Structure Fire - Wed, 23 Nov 2016 10:51 PM
[pubdate] => Wed, 23 Nov 2016 10:51 PM
)
)
)
アレイの最後の部分をエコーする方法はありますか?このセクション:このコードで
[title] => E ST ELMO RD/SHERATON AVE
[link] => http://www.ci.austin.tx.us/fact/default.cfm
[description] => AFD - 4700 S Congress Ave - BOX -Structure Fire - Wed, 23 Nov 2016 10:51 PM
[pubdate] => Wed, 23 Nov 2016 10:51 PM
:
echo $xml->channel->item->link;
私はあなたが間違ったコードを使用している
Notice:Trying to get property of non-object
なぜforeachが必要ですか? 'echo $ xml-> channel-> item-> link;' – bansi
フィードにはもっと多くのイベントが発生します。私はそれがなくてもできます。私は[@属性]が物事を乱すように感じる。それをスキップする方法はありますか? –
$ array ['channel'] - > item-> linkは動作しますか? – sensorario