$url = 'http://221.232.141.108/hsdcw/news.xml';
$opts = array(
        'http'=>array(
        'method'=>"GET",
        'timeout'=>10,
        )
    );

$context = stream_context_create($opts);
$str = file_get_contents($url, false, $context);
$str = trim($str);
$xml = simplexml_load_string($str,'SimpleXMLElement', LIBXML_NOCDATA); 
$j = json_encode($xml);
file_put_contents('/news.log',$j);

 

posted on 2015-11-19 15:12  jzfan  阅读(181)  评论(0编辑  收藏  举报