XML bir PHP uzantısı olduğunda tarayıcı düzgün CSS ile XML görüntülemek değil

0 Cevap php

I'm using a PHP file to output an XML Document.
I'm using a CSS file to format that XML Document.
My browser (Safari) won't show the formatting unless I feed it a file with an xml extension. I thought the header took precedence over the extension.

parser.php (after php processing)

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="parser.css"?>
<Main>
<Test>This is some test text that should appear in Blue.</Test>
</Main>

parser.css

Main { 
    background-color: gray;
}
Test {
    color: blue;
}

If I save the output of the php file as an xml and view that in the browser, then it properly shows the formatting. But I need to generate the xml on the fly.
Is this expected behavior? I guess I could generate a separate file with php and then forward the browser there.
Or I could tell set my server to parse xml files and then just change the extension of my php file (with all the code in it) to XML. But neither of those seem like they should be necessary.

0 Cevap