setAttributeNS adds a new attribute or changes the value of an attribute with the given namespace and name.
Syntaxelement.setAttribute(namespace, name, value)
namespace is the namespace of the new attribute as a string.
name is the name of the new attribute as a string.
value is the desired value of the new attribute.
This example splits the text in a paragraph element. The new, second child of p2 is the sibling node hat contains the text after the split. data gets the text from the text object.
If the attribute named already exists, then the value of that attribute is changed to the value passed in as part of this function. If it does not exist, then a new attribute node is created.