日期:2014-05-17  浏览次数:20428 次

求助用PHP生成XML文件
我的网站是用一个FLASH加载XML实现音乐在线播放,每次用FTP上传音乐和修改XML很麻烦,,,想用PHP实现动态更新XML文件某再次求助各位高手!!!
现在网站的XML如下:
其中,album name的内容来自数据表“lanmu”,song name的内容来自数据表“songs”,!!!xml路径是/player/xml/list.xml
因为这个XML是两层而且是查询两个表 所以不知道怎么写!!
谢谢各位!!由于本人菜鸟的不行,,恳请最好给出完整代码!!


<?xml version="1.0" encoding="utf-8"?>
<featureset>

<album name="Paper Trail" author="TI" imageUrl="images/TI/image.jpg">
  <song name="56 Bars (Intro)" duration="0 : 34" buy="false" download="true" buyLink="http://www.flabell.com/" downloadSource="player/download/song1.mp3">songs/song3.mp3</song>
  <song name="I'm Illy" duration="3 : 28" buy="false" download="true" buyLink="http://www.flabell.com/" downloadSource="player/download/song1.mp3">songs/song3.mp3</song>
  <song name="Ready For Whatever" duration="3 : 54" buy="false" download="true" buyLink="http://www.flabell.com/" downloadSource="player/download/song1.mp3">songs/song3.mp3</song>
  <song name="On Top Of The World" duration="3 : 24" buy="false" download="true" buyLink="http://www.flabell.com/" downloadSource="player/download/song1.mp3">songs/song3.mp3</song>
  
  </album> 


 <album name="Spring" author="Spring·xiao" imageUrl="images/2.jpg" >
  <song name="On Top Of The World" duration="3 : 24" buy="false" download="true" buyLink="http://www.flabell.com/" downloadSource="player/download/song1.mp3">songs/song3.mp3</song>
  </album>

</featureset>

------解决方案--------------------
呵呵,我用的很原始的方法,就是fopen fwrite之类文件操作函数来搞
------解决方案--------------------
你至少需要给出两个表的关系
------解决方案--------------------
把文件属性设置为可写,然后file_put_contents($xml_file_name, $xmlcurrent);
就可以了