Help outputing xml in correct format using php
Hi all. i try to output xml data using the following php code but
when i run the php script i don't get the xml output in correct format.
PHP Code:
<?
echo" <playing>\n";
echo" <artist>Kambiz</artist> \n";
echo" <song>Shookolat</song> \n";
echo" <image>http://www.somesite.com/song_images/kambiz.jpg</image> \n";
echo" <rating>2.44444</rating> \n";
echo" <songid>3003</songid> \n";
echo" </playing>\n";
?>
I want the xml to be outputed as shown in this pic:
correct output format:
Code:
- <playing>
<artist>Kambiz</artist>
<song>Shookolat</song>
<image>http://www.somesite.com/static/artists/shakila.jpg</image>
<rating>2.44444</rating>
<songid>3003</songid>
</playing>
http://allyoucanupload.webshots.com/...91865848610011
Not correct xml format:
Code:
Kambiz Shookolat http://www.somesite.com/song_images/kambiz.jpg 2.44444 3003
http://aycu13.webshots.com/image/274...6588372_rs.jpg
could any one tell me how to output the xml data in the following format.Thanks
Re: Help outputing xml in correct format using php
Have you sent a Content-type header?
This is required in order to signal to the user agent that the document is of an XML type and should be parsed as such.
PHP Code:
header('Content-type: text/xml; charset=utf-8');
Also, you should never use echo() to output large chunks of content like that. In fact there is simply no need to use any PHP here.