 <p>Never parse XML with regular expressions.</p> <p>Use <code>SimpleXML</code> or <code>DOMDocument</code> instead. Below reimplements all your code with <code>SimpleXML</code>.</p> <pre><code>$url = 'http://rss.sonibyte.com/rssfeed/56.xml'; $rss = simplexml_load_file($url); $items = $rss-&gt;channel-&gt;item; // first item is this: $items[0]; // first title: $items[0]-&gt;title; // first url: $items[0]-&gt;enclosure['url']; $data = array(); foreach ($items as $item) { $data[] = array( 'title' =&gt; (string) $item-&gt;title, 'mp3' =&gt; (string) $item-&gt;enclosure['url'], ); } $jsdata = json_encode($data); </code></pre> <p>Your javascript:</p> <pre><code>$(document).ready(function(){ var playerdata = &lt;?php echo htmlspecialchars($jsdata, ENT_NOQUOTES, 'utf-8');?&gt;; new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_1", cssSelectorAncestor: "#jp_container_1" }, playerdata, { swfPath: "js", supplied: "mp3, oga", wmode: "window" }); }); </code></pre>