How to set arrays so php write xml file correctly -


i’m stuck, trying figure out code put .php question should arrays xml file “href links”

       $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-code:

<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 optional text link</a> ]]>             </meta>         </track>         <track href="music/adg3com_chuckedknuckles.mp3" title="artist 2 - track 2" target="" rel="">             <meta><![cdata[this 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 optional text]]></meta>         </track>         <track href="http://soundcloud.com/radykal/favorites" title="soundcloud favorites" />     </playlist> </playlists> 

not sure if got question. if doesn't fit, please let me kno , refine question!
how create href attribute in <track>node:

$track = $xml ->  createelement ("track"); $href = $xml->createattribute('href'); $href->value="http://soundcloud.com/djlewisvi/afrojack-lionheart"; $track->appendchild($href); $track = $playlist -> appendchild ($track); 

see working: http://codepad.viper-7.com/uc9j2y


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -