|
DOMDocument::registerNodeClassRegister extended class used to create base node type Description
public bool DOMDocument::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. Parameters
Return Values
Returns Changelog
Examples
Example #1 Adding a new method to DOMElement to ease our code
<?php The above example will output: <?xml version="1.0"?> <root><child foo="bar"/></root>
Example #2 Retrieving elements as custom class
<?php The above example will output: string(9) "myElement" text in child
Example #3 Retrieving owner document When instantiating a custom DOMDocument the ownerDocument property will refer to the instantiated class, meaning there is no need (and in fact not possible) to use DOMDocument::registerNodeClass with DOMDocument
<?php The above example will output: string(13) "myDOMDocument" string(18) "myOtherDOMDocument" |