XML file in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ammu
    New Member
    • Aug 2011
    • 78

    XML file in PHP

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
    
    	<param name="mp3" value="Aise Na Mujhe.mp3|musicfiles/49_All_Praise_to_You__Eternal_Lord.mp3|musicfiles/49_Christians_Awake.mp3|musicfiles/49_Comfort_and_Joy.mp3|musicfiles/49_Down_from_His_Glory.mp3|musicfiles/49_Jesus__You_re_Worth_Everything.mp3|musicfiles/49_Jesus_Christ_is_Risen_Today.mp3|musicfiles/49_Mother_s_Christmas_Night.mp3|musicfiles/49_Rebuilding.mp3|musicfiles/49_Saw_You_Never.mp3|musicfiles/49_The_Love_of_God_is_Greater_Far.mp3" />
    	
    	
    
    	
    	<param name="title" value="Aise Na Mujhe.mp3" />
    	<param name="height" value="150" />
    	<param name="width" value="225" />	
    	<param name="bgcolor1" value="fbdb03" />
    	<param name="bgcolor2" value="fbdb03" />
    	<param name="buttoncolor" value="090909" />
    	<param name="buttonovercolor" value="0aaf01" />
    	<param name="slidercolor1" value="babababa" />
    	<param name="slidercolor2" value="cccccc" />
    	<param name="sliderovercolor" value="10a905" />
    	<param name="textcolor" value="000000" />
    	<param name="playlistcolor" value="813d07" />
    	<param name="currentmp3color" value="ffffff" />
    	<param name="scrollbarcolor" value="000000" />
    	<param name="scrollbarovercolor" value="288404" />
    	<param name="showvolume" value="1" />
    	<param name="showinfo" value="1" />
    	
    	
    </config>
    This is my XML file. and I am using swf player to play the songs.
    My problem is I want to fetch the data(mp3 file in my musicfile folder and path in my database) from phpmyadmin database to this xml file. Is it possible?

    please help me friends........ ..

    --Ammu
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Yes it's possible. You need to connect to your database using combination of the following functions: mysql_connect() mysql_select_db (), mysql_query() and mysql_fetch_<ty pe>();

    Checkout the PHP manual at php.net if you don't know how to use any of these functions.

    Good luck,


    Dan

    Comment

    • Ammu
      New Member
      • Aug 2011
      • 78

      #3
      Thank you for your response......

      yes i know these functions to fetch the data from database. But my probelm is i want to write these codes in xml file. my file is songs.xml
      Code:
      $conn=mysql_connect("localhost","root","")or die("Unable to connect");
      $select=mysql_select_db("sample",$conn) or die("Unable to connect");
      i tried to write this php connection code in xml file but not working shows error

      --Ammu

      Comment

      • Luuk
        Recognized Expert Top Contributor
        • Mar 2012
        • 1043

        #4
        Code:
        <?php
        
        $string = <<<XML
        <?xml version="1.0" encoding="UTF-8"?>
          <config>
          </config>
        </xml>
        XML;
        
        $xml = new SimpleXMLElement(<<<EOXML
        <?xml version="1.0" encoding="UTF-8"?>
        <config>
        </config>
        EOXML
        );
        
        $item = $xml->addChild('param', '');
        $item->addAttribute('name', 'mp3');
        $item->addAttribute('value', 'something');
        
        $item = $xml->addChild('param', '');
        $item->addAttribute('name', 'height');
        $item->addAttribute('value', '150');
        
        echo $xml->asXML();
        
        ?>

        Comment

        Working...