DOMDocumentFragment makes it easy to add (or replace)
nodes. Individually creating nodes using DOM methods can
be tedious. Instead, do something like this:
/**
* Create fragment of colgroup
* @param DOMDocument $doc The DOMDocument
* @return DOMDocumentFragment
*/
function makeFragment($d){
$chunk = <<<HTML
<colgroup>
<col class="c1"/>
<col class="c2"/>
<col class="c3"/>
<col class="c4"/>
</colgroup>
HTML;
$fragment = $d->createDocumentFragment();
$fragment->appendXML($chunk);
return $fragment;
}