DOMNode read only exception

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

class HtmlTable extends DOMElement                                              
        public function __construct($height, $width)                            
                for ($i = 0; $i < $height; ++$i) {                              
                        $row = $this->appendChild(new DOMElement("tr"));        
                        for($j = 0; $j < $width; ++$j) {
                                $row->appendChild(new DOMElement("td"));

$document = new DOMDocument("1.0", "UTF-8");
$document->registerNodeClass("DOMElement", "HtmlTable");
$document->appendChild(new HtmlTable(3, 2));

Running the above says:

Fatal error: Uncaught exception 'DOMException' with message 'No Modification
Allowed Error' in /home/www/a.php:9
Stack trace:
#0 /home/www/a.php(9): DOMNode->appendChild(Object(DOMElement))
#1 /home/www/a.php(19): HtmlTable->__construct(3, 2)
  thrown in /home/www/a.php on line 9

How can I make the class above useful. I can provide a DOMDocument if

Site Timeline