Whats the difference between setAttribute & setAttribute


Whats the difference between setAttribute & setAttributeNode?

我现在正在玩PHP的DOMDocument。正如问题所述,这两种方法之间有什么区别(除了需要将DOMAttr传递到setAttributeNode之外),在什么情况下应该分别使用?

我记得,它没有太多内容。除了您已经确定的内容之外,主要的区别是setAttributeNode不能同时用于为属性设置值,只能用于设置其名称。

实际上,这是一种在DOM之外准备属性以便稍后插入的方法。

setAttribute是一种更快的方法;它允许对名称和值进行规定。