Sign in Join
FPDoc Onlineexperiment

TDOMNamedNodeMap.SetNamedItem function

Member of TDOMNamedNodeMappublicIn unit Laz2_DOM

Sets the value for a named item to the specified node.

Declaration

pascal
function SetNamedItem(arg: TDOMNode): TDOMNode

Arguments

arg

Node with the name and value added/updated in the method.

Function result

Node replaced in the named node map, or Nil when the node was added.

Description

SetNamedItem is a TDOMNode function used to store the named node in arg in the node map. This may require inserting a new entry or updating an existing one.

SetNamedItem calls ValidateInsert to determine whether the node is valid, and the parent for the node map is updatable. If the response code contains a non-zero value, an EDOMError exception is raised with the response code as the error constant.

SetNamedItem calls the FindSorted method to get the ordinal position for the node in arg. If a node with the same name already exists, it is replaced. Otherwise, the node is inserted at the position needed in the sorted node list.

The node type, passed as an argument to the constructor, is used to determine whether additional actions are needed to update the node / node map. For attribute nodes (TDomAttr), the OwnerElement is cleared in the old node (when needed). The OwnerElement in the new node is set to the DOM element which owns the attribute.

The return value is set to Nil if the node in arg was added to the map. Otherwise, the return value contains the node which was replaced.

SetNamedItem is called from methods like SetAttributeNode and SetAttributeNodeNS in TDOMElement.

Use GetNamedItem to retrieve a node from the map with a specified name.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.