【发布时间】:2016-03-06 15:45:28
【问题描述】:
我正在尝试使用 CGI Perl 在一个简单的 HTML 表中显示 XML 内容(这是一个 SOAP 请求)。但是,XML 内容在内部被截断 表格单元格。任何人都可以提出一个解决方案来正确呈现 XML HTML 页面?
下面是代码:
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $qry = new CGI;
&show_html();
sub show_html {
$qry->header();
$qry->start_html(-bgcolor=>'#FFFFFF', -title=>'Rendering XML');
my $body = &display_page();
print $body;
$qry->end_html;
}
sub display_page {
my $html = qq{
<table border="1">
<tr>
<th> Key </th>
<th>Value</th>
</tr>
<tr>
<td> SOAP </td>
<td>POST /Quotation HTTP/1.0 Host: www.demohost Content-Type: text/xml; charset=utf-8 Content-Length: nnn <?xml version="1.0"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.demourl1/2001/12/soap-envelope" SOAP-ENV:encodingStyle="http://www.demourl2/2001/12/soap-encoding" > <SOAP-ENV:Body xmlns:m="http://www.demourl3/quotations" > <m:GetQuotation> <m:QuotationsName>MiscroSoft</m:QuotationsName> </m:GetQuotation> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
</td>
</tr>
</table>
};
return $html;
}
【问题讨论】:
-
请不要在调用 Perl 子例程时使用 & 符号
&。自 17 年前发布 Perl v5.5 以来,这一直是不正确的