【发布时间】:2018-08-22 07:29:21
【问题描述】:
我在这里做错了什么?
<?php
$xml=simplexml_load_file("<dict>
<key>ChannelID</key>
<string>example</string>
<key>ChannelDVRs</key>
<array>
<dict>
<key>id</key>
<string>LIVE</string>
<key>name</key>
<string>example1111</string>
<key>description</key>
<string>Live</string>
<key>logoUrl</key>
<string>http://www.example.com/logos/190x110/298.jpg</string>
<key>logoUrlSD</key>
<string>http://www.example.com/logos/190x110/298.jpg</string>
<key>isVOD</key>
<string>false</string>
<key>StreamURL</key>
<string>exampleessssssssssss test</string>
</dict>
</array>
</dict>")
or die("Error: Cannot create object");
foreach ($xml->string as $output) {
echo "$output <br>";
}?>
如果有办法得到最后一个字符串 exampleessssssssssss test 我不需要使用 foreach。感谢您的帮助;)
【问题讨论】:
-
看
load_file...或php.net/manual/en/function.simplexml-load-string.php -
那里是 url 链接,结果我只得到
example -
哦,这不是您的实际代码。而不是
What am I doing wrong here?,您应该描述当前发生的事情。这个问题真的是I don't need to use foreach?,下面用end回答。