problem displaying XML on different browser

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • El Durango

    #1

    problem displaying XML on different browser

    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,$stat ename,$stationn ame,$station,%x mlHash) = @_;
    print <<__XML
    <?xml version="1.0"?>
    <weather>
    <station stationId ="$station" stationName="$s tationname" state="$state">
    <observationTim e>$xmlHash{"obs ervationTime"}</observationTime >
    <currentWeather >$xmlHash{"weat her"}</currentWeather>
    <temprature>$xm lHash{"tempratu re"}</temprature>
    <wind>$xmlHash{ "windMph"} mph from $xmlHash{"windD irection"}</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.



  • Martin Honnen

    #2
    Re: problem displaying XML on different browser



    El Durango wrote:
    [color=blue]
    > 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,$stat ename,$stationn ame,$station,%x mlHash) = @_;
    > print <<__XML
    > <?xml version="1.0"?>
    > <weather>
    > <station stationId ="$station" stationName="$s tationname" state="$state">
    > <observationTim e>$xmlHash{"obs ervationTime"}</observationTime >
    > <currentWeather >$xmlHash{"weat her"}</currentWeather>
    > <temprature>$xm lHash{"tempratu re"}</temprature>
    > <wind>$xmlHash{ "windMph"} mph from $xmlHash{"windD irection"}</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.[/color]

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

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    • El Durango

      #3
      Re: problem displaying XML on different browser


      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:40f7f18b$1 @olaf.komtel.ne t...[color=blue]
      >
      > Make sure your CGI sends the right HTTP response header
      > Content-Type: text/xml
      > before the markup.
      >[/color]

      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('Conten t-type' => 'text/xml');


      Comment

      • Martin Honnen

        #4
        Re: problem displaying XML on different browser



        El Durango wrote:[color=blue]
        > "Martin Honnen" <mahotrash@yaho o.de> wrote
        >[color=green]
        >>Make sure your CGI sends the right HTTP response header
        >> Content-Type: text/xml
        >>before the markup.
        >>[/color]
        >
        > 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('Conten t-type' => 'text/xml');[/color]

        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/

        Comment

        • El Durango

          #5
          Re: problem displaying XML on different browser

          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


          Comment

          Working...