Re: php xml mozilla confusion
David Walker wrote:
[color=blue]
>
> Just use the long type for PHP - ie use <?php instead of <? - if you've got
> short tags enabled in PHP.ini and you have access to it, disable that
> setting - its much easier than messing around with silly ways to make XML
> tags display correctly.
>[/color]
I gave it a try but php doesn't seem to be bothered with using
echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
while I've got the short tags enabled.
Joshua's suggestion did the trick solving the problem by adding
<? header ("Content-Type: text/xml"); ?>
I can't change the server setting because loads of pages have to be
altered if I do.
Prodoc
php xml mozilla confusion
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: php xml mozilla confusion
Prodoc wrote:[color=blue]
> stephan beal wrote:
>[color=green]
>> Prodoc wrote:
>>[color=darkred]
>>> <?
>>> echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
>>> ?>[/color]
>>
>>
>>
>> That will confuse PHP. Try:
>> echo "<"."?xml.. .. ?".">";
>>
>> i.e., separate the < and ? characters so PHP doesn't try to parse that as
>> PHP.
>>[/color]
>
> Yeah, you're right, stupid mistake, I changed it to echo... in the first
> place because otherwise it would have started with <? and that confused
> php as well. Though the problem isn't solved by changing it now.
>
> Same result, same problem...
>
> Prodoc
>[/color]
A .xml file has a text/xml mime type. A .php file doesn't. Make this the
first line of your .php file:
<? header ("Content-Type: text/xml"); ?>
Leave a comment:
-
php xml mozilla confusion
I created two different files with almost the exact same content.
file.xml contains pure xml data
file.php contains the exact same data except the first line, this on is
changed to
<?
echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
?>
instead of just
<?xml version="1.0" encoding="utf-8"?>
If I request the xml file in Mozilla or IE it displays the xml content
like those browsers normally do (a nice colorfull tree structure) but if
I request the php file only IE displays it the exact same way as the xml
file (nice and colrfull again), Moz outputs one straight line of text.
Is this a php problem where IE interprets it wrong again and desides to
display it the xml way or is this a browser problem where Moz interprets
it wrong (because it might only display it as nice and colorfull if it
has the xml extension)?
Prodoc
Tags: None
Leave a comment: