html - PHP adds "<head/>" to any xml output -


not sure whats going on here code:

$template = '   <?xml version="1.0" encoding="utf-8" standalone="yes"?>   <categories>     <category>     </category>   </categories>'; echo $template; 

but comes out on web browser

<?xml version="1.0" encoding="utf-8" standalone="yes"?> <head/><categories>   <category>   </category> </categories> 

and when change code slightly

<?xml version="1.0" encoding="utf-8" standalone="yes"?> categories>   <head/><category>   </category> </categories> 

notice removed "<" , head attached next "<". on earth going on here? know is?

are setting content type header before outputting content in browser? if not, browser default text/html , add header tag (not sure though).

header("content-type: text/xml");  

and if browser not adding tag, make sure don't output else xml in response, maybe echoing content after html tag , header has no closing tag (worth check).

remember headers must go before other content, otherwise error.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -