Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: php to xml

  1. #1
    New Coder
    Join Date
    Jun 2012
    Posts
    28
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Exclamation php to xml

    Hi hope some one can help me out with this. Basically i need to transfer data from a php array to xml. The code in php works out the time of day and weekly program schedule . example at www.vikingradio.net can some one show me how i transfer this info to xml . Much appreciated with any help

    ron



    note hope i got this code right this time to display correctly on forum


    Code:
    <?php
    	include("data.php");
    
    echo "<div class='Shows'>";
    echo "<div class='day'>" . date("l",strtotime($showday)) . " " . date("G:i:s",$UKTime) . "</div>";
    for ($i=$Si;$i<$Ei;$i++) {
    	$tShow = (object) $thisShows[$i];
    	echo "<div class='Sitem'>\n";
    	
    	echo "<div class='indicator'>" . ($i==$showK?"ON AIR NOW:":"&nbsp;") . "</div>";echo '<img src="'.$playing.'">';
    	echo "<div class='showtime'>" . str_pad($tShow->start,2,"0",STR_PAD_LEFT) . ".00-" . str_pad($tShow->end,2,"0",STR_PAD_LEFT) . ".00</div>";
    	echo "<div class='descr'>" . $tShow->descr;
    		if ($tShow->descr_long) echo "<div class='descr_long'>" . $tShow->descr_long . "</div>";
    	echo "</div>";
    	echo "<div class='sep'></div>";
    	echo "</div>\n";
    }
    	echo "<p class='pclear'></p>\n";
    echo "</div>";
    
    ?>
    Last edited by Alex Vincent; 10-05-2012 at 05:39 PM. Reason: adding closing code tag

  • #2
    New Coder
    Join Date
    Jun 2012
    Posts
    28
    Thanks
    6
    Thanked 0 Times in 0 Posts
    sorry admin cannot get inline for code. please explain how ron

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    I'm not sure I understand the question - but since you have PHP, you can write XML all day long if you want from that PHP script. You just need to come up with the right XML language, even if it means you invent that language.

    About the only thing you'd need to add to your script (besides the XML language) is the following line:

    Code:
    header("Content-type: application/xml");
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •