Php generates an xml string. I now have a Retrieved result set USER_ID1USER_NAME. small Zhang POINT80USER_ID2USER_NAME Xiao Li POINT60USER_ID3USER_NAME Xiao Wang POINT70 wants to generate an xml string as follows & quot; & lt ;? Xmlversion1.0encodingU php generates xml strings
I now have a Retrieved result set.
USER_ID = 1
USER_NAME = Xiaozhang
POINT = 80
USER_ID = 2
USER_NAME = Xiao Li
POINT = 60
USER_ID = 3
USER_NAME = John
POINT = 70
The xml string to be generated is as follows:
"
1 80
2 Xiao Li 60
3 John 70
";
Ask you how to implement it.
------ 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 the source code...
Add the header ('content-Type: text/XML') before echo to the standard output xml ');
------ Solution --------------------
That's because the browser parses the XML string as an html document. you can view the complete result by checking the source code.
Add a header ('content-type: text/xml; charset = UTF-8 ') at the beginning of the code ');,
And
$ Xml = <
In
Everything OK