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
Post a Comment