iTP Active Transaction Pages (iTP ATP) Programmer's Guide
XML for ATP Add-On Module
iTP Active Transaction Pages (iTP ATP) Programmer’s Guide—522292-002
5-54
Methods
Output
<name test="true">Jenny Mabry</name>
setAttributeNode
Adds a new attribute. If an attribute with the name (nodeName) is already present in
the element, it is replaced by the new one.
Syntax
ObjXMLDOMAttribute = oXMLDOMElement.setAttributeNode(newAttr)
Parameters
newAttr – The XMLDOMAttribute Object
node to add to the attribute list.
Return Value
Object – If the newAttr attribute replaces an existing attribute, the replaced
XMLDOMAttribute node is returned. Otherwise null is returned.
ATPException
The following list shows the possible error-detail codes for the ATPException,
where error code is equal to ATP_ERR_DOM_EXCEPTION.
•
WRONG_DOCUMENT_ERR(4): This error-detail code is raised if newAttr
was created from a different document than the one that created the element.
•
NO_MODIFICATION_ALLOWED_ERR(7): This error-detail code is raised if
this node is read-only.
•
INUSE_ATTRIBUTE_ERR(10): This error-detail code is raised if newAttr is
already an attribute of another XMLDOMElement Object. The DOM user must
explicitly clone XMLDOMAttribute Object
nodes to re-use them in other
elements.
Example
var doc = new XML.DOMDocument;
doc.load("sample.xml");
var root = doc.documentElement;
var node = root.childNodes.item(1).childNodes.item(1);
var attr = doc.createAttribute("test");
node.setAttributeNode(attr);
println(node.xml);
Output
<name test="">Jenny Mabry</name>