PHP generates XML string resolution

Source: Internet
Author: User
PHP generates an XML string
I now have a search result set.
user_id = 1
User_name= Xiao Zhang
Point = 80

USER_ID = 2
User_name= Xiao Li
Point = 60

USER_ID = 3
User_name= Xiao Wang
Point = 70

The string to generate an XML is as follows
"



<> 1 < name="">
<>

2 Xiao Li -


3 Xiao Wang -


";
I ask you how to achieve the hero AH











------Solution--------------------
PHP code
 $xml = << 
   
     xml;while ($row = Mysql_fetch_assoc ($queryResult)) {$xml .=<< 
          
     
     
       {$row [' user_id ']} 
           
     
     
       {$row [' user_name ']} 
      
     
       {$row [' point ']} 
      xml;}
   $xml .=<< 
      
      
      xml;
   
    
------Solution--------------------
Right-click Source code ...
want the standard output XML to precede echo with the header (' Content-type:text/xml ');
------Solution--------------------
That's because the browser parses the XML string as an HTML document, and you can see the full result by looking at the source code.
precede the code with a header (' Content-type:text/xml; Charset=utf-8 ');,
and
$xml = << The!--? XML in
is moved to the front, with no output in front.

Everything OK
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.