Php XML提要上使用的get_file_内容返回的URL数据出现问题
我正在使用Php XML提要上使用的get_file_内容返回的URL数据出现问题,php,xml,file-get-contents,Php,Xml,File Get Contents,我正在使用file\u get\u contents()检索xml提要数据以进行解析。然而,使用图像URL,我得到的基本URL前缀是图像URL-如下所示:- 这是我的密码: <? php $context = stream_context_create( array( 'http' => array( 'follow_location' => false ) ) ); $content =file_get_contents("http://xy
file\u get\u contents()
检索xml提要数据以进行解析。然而,使用图像URL,我得到的基本URL前缀是图像URL-如下所示:-
这是我的密码:
<? php
$context = stream_context_create(
array(
'http' => array(
'follow_location' => false
)
)
);
$content =file_get_contents("http://xyogasangeetax.api.channel.livestream.com/2.0/latestclips.xml", false, $context);
$data = new SimpleXmlElement($content);
foreach($data->channel->item as $entry)
{
if ($media = $entry->children('media', TRUE)) {
$attributes = $media->content->attributes();
$src = $play_attributes['url'];
if ($media->thumbnail) {
$attributes = $media->thumbnail->attributes();
$imgsrc = (string)$attributes['url'];
echo "<img src=\"'$imgsrc'\" alt=\"\" \/>";
}
}
$pub_date= explode("-",$entry->pubDate);
echo date('F d,Y',strtotime(trim($pub_date[0])));
}
?>
请删除不需要的引号: 改变
echo "<img src=\"'$imgsrc'\" alt=\"\" \/>";
echo "<img src=\"$imgsrc\" alt=\"\" \/>";
echo”“;
到
echo”“;