Home >Backend Development >PHP Tutorial >求教一个PHP采撷代码的写法
求教一个PHP采集代码的写法
请问大婶 如果将一个XML完整的采集到PHP
如:
http://www.cailele.com/static/ssc/newlyopenlist.xml
怎么使用PHP怎么采集后并保证采集输出的与XML完全一致
-
------解决方案--------------------
$ch = curl_init();<br /><br />curl_setopt($ch, CURLOPT_URL, "http://www.cailele.com/static/ssc/newlyopenlist.xml");<br /><br />curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); <br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />$r = curl_exec($ch);<br />curl_close($ch);<br />header("content-type:text/xml");<br />echo $r;