Hi! I don't quite understand how to output xml. I get an error message because after my xml there is "HTTP/1.0 200 OK" Something like </granularity></Identify></OAI-PMH>HTTP/1.0 200 OK I guess it is the line "HTTP/1.0 200 OK Content-Type: text/html X-Powered-By: Perl Dancer 1.1805 1" which I am trying to disable. How? Right now I create XML by using HTTP::OAI, i.e. $response->set_handler( XML::SAX::Writer->new( Output => \*STDOUT ) ); $response->generate; Thanks in advanvce!
Maurice Mengel <mauricemengel@gmail.com> writes:
I don't quite understand how to output xml. I get an error message because after my xml there is "HTTP/1.0 200 OK"
Something like </granularity></Identify></OAI-PMH>HTTP/1.0 200 OK
I guess it is the line "HTTP/1.0 200 OK Content-Type: text/html X-Powered-By: Perl Dancer 1.1805 1" which I am trying to disable. How?
Right now I create XML by using HTTP::OAI, i.e.
$response->set_handler( XML::SAX::Writer->new( Output => \*STDOUT ) ); $response->generate;
You should return your response as a string[1], not write it to STDOUT. What you are doing is actually sending your XML out *before* all the HTTP handling happens; try this instead: get '/example/' => sub { my $xml; $response->set_handler( XML::SAX::Writer->new( Output => \$xml ) ); $response->generate; return $xml; } More efficient choices may also exist for getting this out the way you want. Daniel Footnotes: [1] ...other options like a file handle exist, but are more complex. -- ✣ Daniel Pittman ✉ daniel@rimspace.net ☎ +61 401 155 707 ♽ made with 100 percent post-consumer electrons
participants (2)
-
Daniel Pittman -
Maurice Mengel