我正在尝试从xml文件中获取图像网址(使用php codeigniter rest服务器)并将其显示在我的应用中,但由于某些原因,我无法完成它。
我以这种形式重新排列了数据
"feeds": [
{
"title": "2020 Land Rover Defender completes gruelling test in Kenya",
"description": "<p><a href=\"https://sg.news.yahoo.com/2020-land-rover-defender-completes-082000135.html\"><img src=\"http://l1.yimg.com/uu/api/res/1.2/8wiBfVQ01uLPeFQ82ueocA--/YXBwaWQ9eXRhY2h5b247aD04Njt3PTEzMDs-/http://media.zenfs.com/en-GB/homerun/motor1_uk_340/5d31a7b04816caebc23cde0963829f1c\" width=\"130\" height=\"86\" alt=\"2020 Land Rover Defender completes gruelling test in Kenya\" align=\"left\" title=\"2020 Land Rover Defender completes gruelling test in Kenya\" border=\"0\" ></a>The prototype was modified to integrate a raised air intake.<p><br clear=\"all\">"
}
]
您可以看到<img />
标签是description
行内的字符串形式。我使用str_get_html()
函数来获取图像URL,并设法获取了它。
但是
由于某种原因,结果是这种形式
"@attributes": {
"img_url": "http://l1.yimg.com/uu/api/res/1.2/8wiBfVQ01uLPeFQ82ueocA--/YXBwaWQ9eXRhY2h5b247aD04Njt3PTEzMDs-/http://media.zenfs.com/en-GB/homerun/motor1_uk_340/5d31a7b04816caebc23cde0963829f1c"
}
在@attributes
中,我无法在应用程序中显示图像URL。