Professional Web Applications Themes

php xml mozilla confusion - PHP Development

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 ...

  1. #1

    Default 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

    Prodoc Guest

  2. #2

    Default Re: php xml mozilla confusion

    Prodoc wrote:
    > stephan beal wrote:
    >
    >> Prodoc wrote:
    >>
    >>> <?
    >>> echo ("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    >>> ?>
    >>
    >>
    >>
    >> That will confuse PHP. Try:
    >> echo "<"."?xml.... ?".">";
    >>
    >> i.e., separate the < and ? characters so PHP doesn't try to p that as
    >> PHP.
    >>
    >
    > 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
    >
    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"); ?>

    Joshua Ghiloni Guest

  3. #3

    Default Re: php xml mozilla confusion

    David Walker wrote:
    >
    > 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.
    >
    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

    Prodoc Guest

Similar Threads

  1. emf confusion
    By Steve Russell in forum Macromedia Freehand
    Replies: 2
    Last Post: May 13th, 10:17 AM
  2. ai. vs pdf confusion
    By Johanna_O.@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 19
    Last Post: April 21st, 06:54 PM
  3. Net Confusion
    By Dave Beauchemin [MVP] in forum ASP.NET Web Services
    Replies: 0
    Last Post: August 11th, 08:56 PM
  4. CD/RW Confusion?
    By Bill R in forum Windows XP/2000/ME
    Replies: 6
    Last Post: July 8th, 06:26 PM
  5. eps confusion
    By Elliott-Fay webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 0
    Last Post: July 7th, 07:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139