I'm playing around with PHP's DOMDocument at the moment. As the question states, what are the differences between these two methods (other than needing to pas a DOMAttr to setAttributeNode) and in what situations should each be used?
As I recall, there's not a lot in it. The main difference, other than the one you've identified, is setAttributeNode
cannot be used to simultaneously set a value for the attribute, only its name.
In effect, it's a means of preparing an attribute, off the DOM, for insertion at a later point.
setAttribute
is a quicker means of doing this; it allows the stipulation of both the name and value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With