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?
I’m playing around with PHP’s DOMDocument at the moment. As the question states, what
Share
As I recall, there’s not a lot in it. The main difference, other than the one you’ve identified, is
setAttributeNodecannot 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.
setAttributeis a quicker means of doing this; it allows the stipulation of both the name and value.