PHP DOM在单选按钮之间添加新行

时间:2013-08-26 20:18:33

标签: php

我想在单选按钮之间添加一个新行。

我能够将文本添加到我的单选按钮,但是“\ n”的createTextNode确实有效...虽然'\ n'显示在HTML上...但是“\ n”不是也不是掉线。

$showXLS = new DOMDocument();

$showXLS->formatOutput = true;
$showXLS->preserveWhiteSpace = false;
$sXLSSpan = $showXLS->createElement('Span');
$showXLS->appendChild($sXLSSpan);
$sXLSSpan->setAttribute('id','saveOptions');
$sXLSSpan->setAttribute('style','VISIBILITY');

$sXLSDiv = $showXLS->createElement('Div');
$sXLSSpan->appendChild($sXLSDiv);
$sXLSDiv->setAttribute('id','showingOptions');
$sXLSDiv->setAttribute('align','right');

$sXLSForm = $showXLS->createElement('Form');
$sXLSDiv->appendChild($sXLSForm);
$sXLSForm->setAttribute('id','sXLSForm');
$sXLSForm->setAttribute('action','printTest.php');
$sXLSForm->setAttribute('method','POST');

$sXLSInput1Text = $showXLS->createElement('label','<b>Save Directory</b>');
$sXLSForm->appendChild($sXLSInput1Text);
$sXLSInput1Text->appendChild($showXLS->createTextNode("\n"));


$sXLSInput1 = $showXLS->createElement('input');
$sXLSInput1Text->appendChild($sXLSInput1);
$sXLSInput1->setAttribute('type','radio');
$sXLSInput1->setAttribute('name','save');
$sXLSInput1->setAttribute('value','saveDirectory');
$sXLSInput1->setAttribute('id','saveDirectory');


$sXLSInput2Text = $showXLS->createElement('label','Save Email');
$sXLSForm->appendChild($sXLSInput2Text);
$sXLSInput2Text->appendChild($showXLS->createTextNode("\n"));

/////////////// new line here

$sXLSInput2 = $showXLS->createElement('input');
$sXLSInput2Text->appendChild($sXLSInput2);
$sXLSInput2->setAttribute('type','radio');
$sXLSInput2->setAttribute('name','save');
$sXLSInput2->setAttribute('value','saveEmail');
$sXLSInput2->setAttribute('onClick','getMore()');

1 个答案:

答案 0 :(得分:0)

<br/>
or
createElement("br");

\ n在html中没有任何值