[Overview][Constants][Types][Classes][Procedures and functions][Index] Reference for unit 'Laz2_DOM' (#lazutils)

TDOMNamedNodeMap.SetNamedItem

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

Declaration

Source position: laz2_dom.pas line 402

public function TDOMNamedNodeMap.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

TDOMNamedNodeMap.ValidateInsert

  

Performs actions to determine if an inserted attribute node is valid for its context.

TDOMNamedNodeMap.FindSorted

  

Finds a DOM Node with the specified name in the sorted container.

TDOMElement

  

Implements the DOM Element interface from the DOM specification.

TDOMAttr.Name

  

Represents the name for the DOM Attribute.

TDOMAttr.OwnerElement

  

DOM Element that owns the DOM Attribute node.

TDOMNode.NodeName

  

Name for the DOM node.

EDOMError

  

Base class for exceptions raised in DOM interface classes.


Version 4.0 Generated 2025-05-03 Home