Outputting XML via PHP and SQL <p>Can anyone help me in by telling me how can I output my XML result via PHP? I have an sql database and written the function in PHP to parse the XML and I have debugged the page in Firefox (using the NET tab) which is bringing up a the correct response corresponding to my SQL statement however, I can't actually see the data, its just a blank page.</p> <p>Here is the php file to write the XML:</p> <pre><code>&lt;?php include("classes/database_connection.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('&lt;','&amp;lt;',$htmlStr); $xmlStr=str_replace('&gt;','&amp;gt;',$xmlStr); $xmlStr=str_replace('"','&amp;quot;',$xmlStr); $xmlStr=str_replace("'",'&amp;#39;',$xmlStr); $xmlStr=str_replace("&amp;",'&amp;amp;',$xmlStr); return $xmlStr; } // Opens a connection to a MySQL server $connection=mysql_connect ('www.numyspace.co.uk', '*********', '************'); if (!$connection) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('********', $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the ticket table $query = "SELECT * FROM ticket"; $result = mysql_query($query); header("Content-type: text/xml"); // Start XML file, echo parent node echo '&lt;ticket&gt;'; while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '&lt;tickets '; echo 'ticketID="' . parseToXML($row['ticketID']) . '" '; echo 'locationID="' . parseToXML($row['locationID']) . '" '; echo 'venue="' . parseToXML($row['venue']) . '" '; echo 'tPrice="' . parseToXML($row['tPrice']) . '" '; echo 'date="' . parseToXML($row['date']) . '" '; echo 'availability="' . parseToXML($row['availability']) . '" '; echo 'time="' . parseToXML($row['time']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo '/&gt;'; } // End XML file echo '&lt;/ticket&gt;'; ?&gt; </code></pre> <p>Thank you and any help is much appreciated.</p> <p>EDIT: The page's markup:</p> <pre><code> &lt;ticket&gt;&lt;tickets ticketID="1" locationID="1" venue="The Cluny" tPrice="15" date="2012-04-17" availability="200" time="20:00:00" lat="54.978252" lng="-1.617780" /&gt;&lt;tickets ticketID="2" locationID="1"..../&gt;&lt;/ticket&gt; </code></pre>