Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:45:35+00:00 2026-05-30T22:45:35+00:00

Can anyone help me in by telling me how can I output my XML

  • 0

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.

Here is the php file to write the XML:

<?php
  include("classes/database_connection.php");

    function parseToXML($htmlStr) 
       { 
        $xmlStr=str_replace('<','&lt;',$htmlStr); 
        $xmlStr=str_replace('>','&gt;',$xmlStr); 
        $xmlStr=str_replace('"','&quot;',$xmlStr); 
        $xmlStr=str_replace("'",'&#39;',$xmlStr); 
        $xmlStr=str_replace("&",'&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 '<ticket>';

       while ($row = @mysql_fetch_assoc($result)){
       // ADD TO XML DOCUMENT NODE
       echo '<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 '/>';
     }

   // End XML file
   echo '</ticket>';

?>

Thank you and any help is much appreciated.

EDIT: The page’s markup:

 <ticket><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" /><tickets ticketID="2" locationID="1"..../></ticket>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:45:36+00:00Added an answer on May 30, 2026 at 10:45 pm

    Ensure you have the XML declaration at the top of your XML.

    echo "<?xml version='1.0' ?>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

can anyone help, we have a sql server 2005 database installed (actually its an
Can anyone help me with the trying to write SQL (MS SqlServer) - I
Can anyone help, I have 2 applications and they are nearly identical. they have
Can anyone help me by telling me what is wrong with the following syntax?
Can anyone help - this is driving me mad. I am calling a mysql
Can Anyone help me why x2 prints zero. I guess because of floating point
Can anyone help me how to split /explode verse format to 3 parts? The
Can anyone help me to get good WordPress interview questions and answers. Any link
Can anyone help me in converting scalar type of openCV to basic types like
can anyone help me for the exercise 12.5 of Jason Hickey's book? Basically, the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.