problem displaying XML on different browser

E

El Durango

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

Martin Honnen

El said:
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.
 
E

El Durango

Martin Honnen said:
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');
 
M

Martin Honnen

El said:
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.
 
E

El Durango

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,828
Latest member
LauraCastr

Latest Threads

Top