How to echo xml file in php

前端 未结 10 863
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 04:37

How to print an xml file to the screen in php?

This is not working:

$curl = curl_init();        
curl_setopt ($curl, CURLOPT_URL, \'http://rss.news.y         


        
10条回答
  •  北海茫月
    2020-11-29 05:01

    Am I oversimplifying this?

    $location = "http://rss.news.yahoo.com/rss/topstories";
    print file_get_contents($location);
    

    Some places (like digg.com) won't allow you to access their site without having a user-agent, in which case you would need to set that with ini_set() prior to running the file_get_contents().

提交回复
热议问题