load($url); //读取xml文件 $lst = $doc-&"/> load($url); //读取xml文件 $lst = $doc-&">
Maison > Article > développement back-end > 小弟我想用php读取xml的三个值
我想用php读取xml的三个值
$url="http://www.cailele.com/static/ssc/newlyopenlist.xml";<br /> $doc = new DOMDocument();<br /> $doc->load($url); //读取xml文件<br /> $lst = $doc->getElementsByTagName('row');<br /> for ($i=0; $i<2; $i++) {<br /> $iframe= $lst->item($i);<br /> $t1=$iframe->attributes->getNamedItem('expect')->value;<br /> $t2=$iframe->attributes->getNamedItem('opencode')->value;<br /> $t3=$iframe->attributes->getNamedItem('opentime')->value;<br /> $t1=substr($t1,-9);<br /> kjdata($t2,1,$t1,$t3);<br /> } <br />
$url = "http://www.cailele.com/static/ssc/newlyopenlist.xml";<br />$doc = new DOMDocument();<br />$doc->loadXML(curl_get($url));<br />$lst = $doc->getElementsByTagName('row');<br />for ($i=0; $i<2; $i++) {<br /> $iframe= $lst->item($i);<br /> $t1=$iframe->attributes->getNamedItem('expect')->value;<br /> $t2=$iframe->attributes->getNamedItem('opencode')->value;<br /> $t3=$iframe->attributes->getNamedItem('opentime')->value;<br /> $t1=substr($t1,-9);<br /> kjdata($t2,1,$t1,$t3);<br />}<br /><br />function kjdata() {<br /> echo join(', ', func_get_args()), PHP_EOL;<br />}<br /><br />function curl_get($durl) {<br /> $cookiejar = realpath('cookie.txt');<br /> $t = parse_url($durl);<br /> $ch = curl_init();<br /> curl_setopt($ch, CURLOPT_URL,$durl);<br /> curl_setopt($ch, CURLOPT_TIMEOUT,5);<br /> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);<br /> curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);<br /> curl_setopt($ch, CURLOPT_REFERER, "http://$t[host]/");<br /> curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);<br /> curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);<br /> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);<br /> $r = curl_exec($ch);<br /> curl_close($ch);<br /> return $r;<br />}<br />5,9,6,4,2, 1, 140421023, 2014-04-21 01:55:30