PHP读取XML的方法

<?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)