problem displaying XML on different browser

Discussion in 'XML' started by El Durango, Jul 16, 2004.

  1. El Durango

    El Durango Guest

    Hi I have a simple CGI program that takes data from a data source and posts
    it
    as XML format on the browser, I have tested my program on IE and Mozilla
    and they behave differently. Sometimes XML format is displayed sometimes
    just the data is displayed excluding the elements.

    Here is a snippet of my code that displays the data:

    sub displayInfo{
    my($state,$statename,$stationname,$station,%xmlHash) = @_;
    print <<__XML
    <?xml version="1.0"?>
    <weather>
    <station stationId ="$station" stationName="$stationname" state="$state">
    <observationTime>$xmlHash{"observationTime"}</observationTime>
    <currentWeather>$xmlHash{"weather"}</currentWeather>
    <temprature>$xmlHash{"temprature"}</temprature>
    <wind>$xmlHash{"windMph"} mph from $xmlHash{"windDirection"}</wind>
    </station>
    </weather>
    __XML
    }


    It seems that Mozilla is pretty strict on displaying the data in XML format.
    For instance the following perl block:

    print <<__ERROR
    <?xml version="1.0"?>
    <weather>
    <meta>
    <error>
    Incompatible Data.
    </error>
    </meta>
    </weather>
    __ERROR

    gets displayed as just:
    Incompatible Data.

    As if it were HTML.

    If anyone has any ideas I would appreciate it.
     
    El Durango, Jul 16, 2004
    #1
    1. Advertising

  2. El Durango wrote:

    > Hi I have a simple CGI program that takes data from a data source and posts
    > it
    > as XML format on the browser, I have tested my program on IE and Mozilla
    > and they behave differently. Sometimes XML format is displayed sometimes
    > just the data is displayed excluding the elements.
    >
    > Here is a snippet of my code that displays the data:
    >
    > sub displayInfo{
    > my($state,$statename,$stationname,$station,%xmlHash) = @_;
    > print <<__XML
    > <?xml version="1.0"?>
    > <weather>
    > <station stationId ="$station" stationName="$stationname" state="$state">
    > <observationTime>$xmlHash{"observationTime"}</observationTime>
    > <currentWeather>$xmlHash{"weather"}</currentWeather>
    > <temprature>$xmlHash{"temprature"}</temprature>
    > <wind>$xmlHash{"windMph"} mph from $xmlHash{"windDirection"}</wind>
    > </station>
    > </weather>
    > __XML
    > }
    >
    >
    > It seems that Mozilla is pretty strict on displaying the data in XML format.
    > For instance the following perl block:
    >
    > print <<__ERROR
    > <?xml version="1.0"?>
    > <weather>
    > <meta>
    > <error>
    > Incompatible Data.
    > </error>
    > </meta>
    > </weather>
    > __ERROR
    >
    > gets displayed as just:
    > Incompatible Data.
    >
    > As if it were HTML.


    Make sure your CGI sends the right HTTP response header
    Content-Type: text/xml
    before the markup.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jul 16, 2004
    #2
    1. Advertising

  3. El Durango

    El Durango Guest

    "Martin Honnen" <> wrote in message
    news:40f7f18b$...
    >
    > Make sure your CGI sends the right HTTP response header
    > Content-Type: text/xml
    > before the markup.
    >


    I have done that but my program still behaves differently on the 2 browsers.
    Mozilla Firefox does not even want to show it in XML format.
    Here is the piece of code that sets content-type:
    print $web->header('Content-type' => 'text/xml');
     
    El Durango, Jul 17, 2004
    #3
  4. El Durango wrote:
    > "Martin Honnen" <> wrote
    >
    >>Make sure your CGI sends the right HTTP response header
    >> Content-Type: text/xml
    >>before the markup.
    >>

    >
    > I have done that but my program still behaves differently on the 2 browsers.
    > Mozilla Firefox does not even want to show it in XML format.
    > Here is the piece of code that sets content-type:
    > print $web->header('Content-type' => 'text/xml');


    Is that online so that you could post a URL here that we can visit and
    examine? Otherwise I can't help further I am afraid, if that is Perl
    above you might want to ask in a Perl/CGI group.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Jul 17, 2004
    #4
  5. El Durango

    El Durango Guest

    You know what Martin, it has started to work all of sudden?
    And I did not even touch it?? weird I must say.
    I thank you for your time on this.

    Danke!
    Durango
     
    El Durango, Jul 17, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nita Raju
    Replies:
    1
    Views:
    294
    Chris Hyde
    Dec 15, 2004
  2. doGmaI
    Replies:
    18
    Views:
    649
    Sid Ismail
    Apr 24, 2005
  3. bluebaron
    Replies:
    3
    Views:
    748
    Jonathan N. Little
    Nov 4, 2009
  4. Sean

    different browser with different results

    Sean, May 18, 2005, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    120
    Chad Z. Hower aka Kudzu
    May 18, 2005
  5. Erik Wasser
    Replies:
    5
    Views:
    465
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page