<?php header("content-type:text/html; charset=utf-8"); //設置編碼 $lists = simplexml_load_file('auction_end_tomorrow.xml'); $channel = $lists->channel; $titles = array(); $str=''; foreach($channel->item as $items){ //有多個user,取得的是數組,循環輸出 $str .=$items->title."\r\n";; } $k=fopen("d:\\auction_end_tomorrow.txt","a+");//此處用a+,讀寫方式打開,將文件指針指向文件末尾。如果文件不存在則嘗試創建之 fwrite($k,$str); fclose($k); ?>
PHP讀取XML的方法
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.