Reputation: 170
Not sure whats going on but here is my code:
$template = '
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<categories>
<category>
</category>
</categories>';
echo $template;
But this is what comes out on the web browser
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<head/><categories>
<category>
</category>
</categories>
And when I change the code slightly
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
categories>
<head/><category>
</category>
</categories>
Notice I removed the "<" and the head then attached itself to the next "<". What on earth is going on here? Anyone know what this is?
Upvotes: 1
Views: 136
Reputation: 21769
are you setting the content type header properly before outputting the content in the browser? if not, browser will default to text/html
and will probably add the header tag to it (not sure about this though).
header("Content-type: text/xml");
and if the browser is not adding the tag, make sure that you don't output anything else than the xml in the response, maybe you are echoing the content after the html tag and the header has no closing tag (worth to check).
remember that headers must go before any other content, otherwise you will get an error.
Upvotes: 3