dcarbone / dom-plus
A DOMDocument class wrapper that adds some simple improvements
Requires
- php: >=5.3.3
- lib-libxml: *
README
A simple DOMDocument class wrapper that adds some simple improvements
Inclusion in your Composer application
"require" : { "dcarbone/dom-plus" : "1.3.*" }
This class utilizes the PHP DOMDocument method registerNodeClass to extend several classes.
What this means is that whenever create a new instance of DCarbone\DOMPlus\DOMDocumentPlus
, all DOMNode, DOMElement, DOMText, and DOMCharacterData objects contained within the document are
instantiated as the modified classes I have included in this library.
So if you execute:
$dom = new DOMDocumentPlus; $div = $dom->createElement('div'); echo get_class($div);
Instead of seeing DOMElement, you will see DCarbone\DOMPlus\DOMElementPlus. Same goes for:
$text = $dom->createTextNode('text!'); // returns DCarbone\DOMPlus\DOMTextPlus
Additionally, these methods will also exist if you try to consume XML with this class. However I have not done any testing with XML documents!. If you use this with XML and find issues, please report them
INodePlus
This interface is applied to all concrete classes provided by this library. Click the link above to peruse the provided methods.
DOMDocumentPlus
DOMDocumentPlus has some enhancements inspired by Artem Russakovskii's SmartDOMDocument Class.
DOMElementPlus
DOMElementPlus contains some additional HTML-specific features, such as style and class attribut helper methods