XmlReplaceNode Function

Action

XmlReplaceNode replaces the node passed in parameter hDestNode with the node in parameter hSourceNode. The source node must not be a child of another node - you would have to remove the node first from its current parent. The replaced node can afterwards be used to append to another node.

XmlReplaceNode simply does the following things: Removes hDestNode from the parent and appends hSourceNode to the former parent of hDestNode.

Include file

XmlAPI.bdh

Syntax

XmlReplaceNode( in hDestNode   : number,
                in hSourceNode : number ): boolean;

Return value

  • true if successful

  • false otherwise

Parameter Description
hDestNode XML node handle that will be replaced by hSourceNode
hSourceNode XML node handle that will replace hDestNode

Example

dcltrans
  transaction TMain
  var
    hDocument, hResult, hNewNode : number;
  begin
    hDocument := XmlCreateDocumentFromXml("<root><child1 attr1='avalue1'>childvalue1</child1>"
                  "<child2 attr1= 'avalue2'>childvalue2</child2></root>");
    hNewNode := XmlCreateNodeFromXml("<child3 attr1='avalue3'>childvalue3</child3>");
    hResult := XmlSelectSingleNode(hDocument,"/root");
    XmlReplaceNode(hResult, hNewNode);
  end TMain;