NodeBuilder.addAttribute( name as String, text as String, [namespace as String?] ) as This NodeBuilder object
Add an attribute node to the node tree the builder is building.
Attribute nodes may only be added to element nodes that have had nothing but other attribute nodes added to them.
To add a namespaced attribute, give a prefixed name as the first argument and a namespace URI as the final argument.
const builder = new NodeBuilder(); builder.startElement('example'); builder.addAttribute('xml:lang','en','http://www.w3.org/XML/1998/namespace'); builder.addText('English content'); builder.endElement(); builder.toNode(); // Returns an XML element node equivalent to the following: // <example xml:lang="en" xmlns:xml="http://www.w3.org/XML/1998/namespace"> // English content // </example>