How to generate XML file dynamically using PHP? -
How to generate XML file dynamically using PHP? -
i have generate xml file dynamically @ runtime. please help me in generating below xml file dynamically using php.
<?xml version="1.0" encoding="utf-8"?> <xml> <track> <path>song1.mp3</path> <title>track 1 - track title</title> </track> <track> <path>song2.mp3</path> <title>track 2 - track title</title> </track> <track> <path>song3.mp3</path> <title>track 3 - track title</title> </track> <track> <path>song4.mp3</path> <title>track 4 - track title</title> </track> <track> <path>song5.mp3</path> <title>track 5 - track title</title> </track> <track> <path>song6.mp3</path> <title>track 6 - track title</title> </track> <track> <path>song7.mp3</path> <title>track 7 - track title</title> </track> <track> <path>song8.mp3</path> <title>track 8 - track title</title> </track>
i'd utilize simplexmlelement.
<?php $xml = new simplexmlelement('<xml/>'); ($i = 1; $i <= 8; ++$i) { $track = $xml->addchild('track'); $track->addchild('path', "song$i.mp3"); $track->addchild('title', "track $i - track title"); } header('content-type: text/xml'); print($xml->asxml());
php xml
Comments
Post a Comment