我被困住了,试图弄清楚为 .php 放置什么代码我的问题是 xml 文件的数组应该是什么,尤其是“href 链接”</p>
$xml = new DOMDocument ("1.0","UTF-8");
$playlists = $xml -> createElement("playlists");
$playlists = $xml -> appendChild($playlists);
$playlist = $xml -> createElement ("playlist");
$playlist = $playlists -> appendChild ($playlist);
$track = $xml -> createElement ("track");
$track = $playlist -> appendChild ($track);
$meta = $xml -> createElement ("meta");
$meta = $track -> appendChild ($meta);
$xml->formatOutput = true;
$string_value = $xml->saveXML();
$xml->save("preview.xml");
XML 代码:
<playlists>
<playlist id="pl1">
<track href="music/adg3com_bustedchump.mp3" title="Artist 1 - Track 1" target="http://google.de" rel="covers/cover1.jpg">
<meta>
<![CDATA[ <a href="http://google.de" target="_blank">This is an optional text with a link</a> ]]>
</meta>
</track>
<track href="music/adg3com_chuckedknuckles.mp3" title="Artist 2 - Track 2" target="" rel="">
<meta><![CDATA[This is an optional text]]></meta>
</track>
</playlist>
<playlist id="pl2">
<track href="http://soundcloud.com/djlewisvi/afrojack-lionheart" title="Afrojack - Lionheart" />
<track href="music/adg3com_chuckedknuckles.mp3" title="Artist 3 - Track 3" target="" rel="covers/cover1.jpg">
<meta><![CDATA[This is an optional text]]></meta>
</track>
<track href="http://soundcloud.com/radykal/favorites" title="Soundcloud Favorites" />
</playlist>
</playlists>