OK, lets take a step back here, you are getting confused between what CGI is, and what the file is.

This is what a CGI application should return TO THE WEB SERVER.

-------------------------------------------------- Content-type: text/plain (or text/html and so on) Some-Other: headers (a blank line) The contents of the file goes here --------------------------------------------------

So to send a text file the CGI prints this to STDOUT:

-------------------------------------------------- Content-type: text/plain Hello World! --------------------------------------------------

... and a HTML file

-------------------------------------------------- Content-type: text/html <html> <body> Hello World! </body> </html> --------------------------------------------------

... and an XML file

-------------------------------------------------- Content-type: text/xml <?xml version="1.0" encoding="ISO-8859-1"?> <tag>Hello World!</tag> --------------------------------------------------

I hope by now you see it's quite obvious you can't just spit the output of a CGI into a file and expect a browser to load that file, because you've incorrectly stuffed the extra headers into the file.

It's no wonder the XML parser is freaking out.

If you make a script that uses CGI.pm and adds the headers to the output, you can ONLY run it in a webserver.

It's not useful for producing the file standalone any more.

20070821 Janitored by Corion: Fixed stray </code> tag


In reply to I don't think you understand CGI still by Anonymous Monk
in thread XML::Generator bad header? by hallikpapa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.