I’m using the header() function to turn a file into XML standard.
The problem is when I use <?php header("Content-type: text/xml; charset=utf-8"); ?> it just renders the <?xml version="1.0"?>, without the enconding/charset. Am I using it wrongly?
I’m using the header() function to turn a file into XML standard. The problem
Share
The
header()function just modifies HTTP headers. The code you posted sets aContent-Typeheader, which is important for telling browsers and other clients what type of file you’re serving.The
<?xml version="1.0"?>line you’re talking about is part of the document itself, and not affected by the HTTP headers.Your tags say you’re using DOM to create your XML document. If you change your DomDocument constructor to also pass the charset,
It should output that charset in the XML document.