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