1 回答
TA贡献1788条经验 获得超4个赞
我想到了。
当我最初删除最后两个选项和结束标记时,我留在了SELECT
XSL 样式表中的开始标记中。这导致样式表失败,因为它有一个没有结束标记的开始标记。一旦我SELECT
从 XSL 样式表中删除了标记行并对 PHP 进行了以下更改,一切都完美无缺。
这是对 PHP 的更改:
$openTag = '<select name="shipping_options" id="shipping_options">';
$closeTag = '<option value=\'8!!!0.00\'>Please call for freight pricing</option>
<option value=\'9!!!0.00\'>Please call for international pricing</option>
</select>';
....
else {
// save request and response to file
$fw = fopen ( $outputFileName, 'w' );
fwrite ( $fw, $response );
fclose ( $fw );
// Load XML file
$xml = new DOMDocument;
$xml->load($outputFileName);
// Load XSL file
$xsl = new DOMDocument;
$xsl->load('style.xsl');
// Configure the transformer
$proc = new XSLTProcessor;
// Attach the xsl rules
$proc->importStyleSheet($xsl);
echo $openTag;
echo $proc->transformToXML($xml);
if ($to_height > 0 && $to_height <= 2) {
echo $openTag . 'extra text here' . $closeTag;
}
else {
echo $openTag . $closeTag;
}
}
添加回答
举报