--- Jeremy Vinding <[EMAIL PROTECTED]> wrote:
> I fell incredibly stupid that I can't get such a simple thing to work.
> I'm trying to display the source of XML files without allowing IE to parse
> them, but it still is parsing it:(

Jeremy,

Welcome to the wonderful world "Violating Standards"!  Microsoft, in their 
less-than-infinite
wisdom, decided that their browsers will ignore the Content-type header and instead 
examine the
beginning of the document sent over to determine the type.  There is nothing you can 
do about
this.

However, you can cheat.  

Translate the characters that might cause HTML trouble (e.g., all of the tags in XML 
:) and use an
HTML document.  Here's one way (untested, but it should put you on the right path):

    #!/usr/bin/perl -wT
    use strict;
    use CGI qw/:standard/;
    use HTML::Entities;

    my $xml;
    open XML, "< somedoc.xml" or die $!;
    {
        local $/;
        $xml = <XML>;
    }
    close XML;

    $xml = encode_entities( $xml );
    print 
        header,
        start_html( -title => "An XML Document" ),
        pre( tt( $xml ) ),
        end_html;

Cheers,
Curtis "Ovid" Poe

=====
"Ovid" on http://www.perlmonks.org/
Someone asked me how to count to 10 in Perl:
push@A,$_ for reverse q.e...q.n.;for(@A){$_=unpack(q|c|,$_);@a=split//;
shift@a;shift@a if $a[$[]eq$[;$_=join q||,@a};print $_,$/for reverse @A

__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to