Extending DOM Classes Examples

Class books extends domDocument {
    function __construct() {
        parent::__construct();
    }
    function addBook($title, $author) {
        $titleElement = $this->createElement("title");
        $titleElement->appendChild($this->createTextNode($title));
        $authorElement = $this->createElement("author");
        $authorElement->appendChild($this->createTextNode($author));
        $bookElement = $this->createElement("book");
        $bookElement->appendChild($titleElement);
        $bookElement->appendChild($authorElement);
        $this->documentElement->appendChild($bookElement);
    }
} 
 
© copyright 2003 Bitflux GmbH