Name

renameNode: n, namespaceURI, qualifiedName(3)

Synopsis

Allows Element and Attr type nodes to be renamed. Whenever possible, the nodeName attribute of the target Node is modified directly. If simply changing the name is not possible, a node is created with the new name and the child nodes of the old node are moved to the new node. If the node is an Element node, renaming it will cause it to lose the default attributes of the old node name and gain those corresponding to its new name.

Arguments

n: Node

The node to rename.

namespaceURI: DOMString

The namespace URI for the renamed node.

qualifiedName: DOMString

The new qualified name for the node.

Exceptions

NOT_SUPPORTED_ERR

Thrown if the target nodeType is not ELEMENT_NODE or ATTRIBUTE_NODE, or if the implementation does not support renaming the documentElement.

INVALID_CHARACTER_ERR

Thrown if the new qualified name is not a name according to the contents of the xmlVersion attribute.

WRONG_DOCUMENT_ERR

Thrown if an attempt is made to rename a node from a different document.

NAMESPACE_ERR

Raised if the qualifiedName is malformed or has a prefix but no namespaceURI, or if the reserved xml namespace prefix was used incorrectly.

Java binding

public Node renameNode(Node n, String namespaceURI, 
String qualifiedName) throws DOMException;

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.