<?xml version="1.0" encoding="utf-8"?>
<songs>
<song atitle="Liszert - piano 1" aurl="561621_SOUNDDOGS__so.mp3"/>
<song atitle="Liszert - piano 2" aurl="561623_SOUNDDOGS__so.mp3"/>
<song atitle="相信" aurl="相信.mp3"/>
</songs>
我想用PHP編出上面那種形式的XML
<?xml version="1.0" encoding="utf-8"?>
<Song>
<songTitle>同類</songTitle>
<songArtist>孫燕姿</songArtist>
</Song>
</XML>
我不要這種的,這種的我會了,謝謝
$doc = new DOMDOCUMENT("1.0","utf-8");
//create element
$root_song = $doc->createElement('songs');
$root = $doc->createElement('song');
$text = $doc->createTextNode($flashData);
$root->appendChild($text);
$root_song->appendChild($root);
$doc->appendChild($root_song);
$element = $doc->createElement('xml');
$doc->appendChild($element);
$doc->save("song.xml");