I have this script that runs queries, and outputs it in XML format. Here is a snippet of what comes out if I print to screen:
<?xml version="1.0" encoding="ISO-8859-1"?> <dataset> <cdr> <id>08-15-2007.09 </id> <col2>202</col2> <col3>7</col3> <col4>7</col4> <col5>0</col5> <col6> 0.0</col6> <col7>100</col7> <col8> 1</col8> <col9> </col9> <col10>2007-08-15 09:57:56</col10> </cdr><cdr> <id>08-15-2007.09 </id> <col2>202</col2> <col3>8</col3> <col4>8</col4> <col5>0</col5> <col6>1414.5</col6> <col7>100</col7> <col8> 1</col8> <col9>10608</col9> <col10>2007-08-15 09:57:56</col10> </cdr><cdr> <id>08-15-2007.11 </id> <col2>240</col2> <col3>12</col3> <col4>12</col4> <col5>0</col5> <col6> 0.0</col6> <col7>100</col7> <col8> 2</col8> <col9> </col9> <col10>2007-08-15 11:57:15</col10> </cdr></dataset>
I am trying to push it back to the browser and I get this error in apache log
malformed header from script. Bad header=<?xml version="1.0" encoding= +": rpt.pl
This is how I print the header:
print "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; print "<dataset>\n"; print @output; print "</dataset>";
I got that header from the w3school.com website, so I am a bit confused on what the browser wants. Also, the file I wrote to looks exactly like the above data sample, but much larger, and the browser can't read it.

In reply to 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.