xml提取

时间:2021-07-05 20:05:43
$url = 'http://221.232.141.108/hsdcw/news.xml';
$opts = array(
'http'=>array(
'method'=>"GET",
'timeout'=>,
)
); $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);