Output raw XML using php

By default PHP sets the Content-Type to text/html, so the browsers are displaying your XML document as an HTML page.

For the browser to treat the document as XML you have to set the content-type:

header('Content-Type: text/xml');

Do this before printing anything in your script.

Leave a Comment