PHP: DOMDocument->registerNodeClass() - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

DOMDocument->relaxNGValidate() DOMDocument->normalizeDocument()

Last updated: Sat, 27 Jan 2007

view this page in

# DOMDocument->registerNodeClass()

(no version information, might be only in CVS)

DOMDocument->registerNodeClass() -- Register extended class used to create base node type

## Описание

class DOMDocument {
bool registerNodeClass ( string baseclass, string extendedclass )
}

This method allows you to register your own extended DOM class to be used afterward by the PHP DOM extension.

This method is not part of the DOM standard.

## Список параметров

`baseclass`

  The DOM class that you want to extend. You can find a list of these classes in the chapter introduction.

  Of course, you won't be able to register a class extending DOMDocument but you can always start your document by instanciating your own extending class.

`extendedclass`

  Your extended class name. If `NULL` is provided, any previously registered class extending `baseclass` will be removed.

## Возвращаемые значения

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

## Примеры

Пример 1. Adding a new method to DOMElement to ease our code

`<?php
class myElement extends DOMElement {
function appendElement($name) {
return $this->appendChild(new myElement($name));
}
}
class myDocument extends DOMDocument {
function setRoot($name) {
return $this->appendChild(new myElement($name));
}
}
$doc = new myDocument();
$doc->registerNodeClass('DOMElement', 'myElement');
// From now on, adding an element to another costs only one method call !
$root = $doc->setRoot('root');
$child = $root->appendElement('child');
$child->setAttribute('foo', 'bar');
echo $doc->saveXML();
?>`

Результат выполнения данного примера:

    <?xml version="1.0"?>
    <root><child foo="bar"/></root>

add a note User Contributed Notes
DOMDocument->registerNodeClass()
There are no user contributed notes for this page.
DOMDocument->relaxNGValidate() DOMDocument->normalizeDocument()

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST