Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Plant SCADA

XMLNodeAddChild

  • Last UpdatedJul 18, 2023
  • 1 minute read

Creates an element node with the specified Name and Namespace and appends the node to the end of the list of child nodes of specified parent node in the XML document.

Syntax

INT XMLNodeAddChild(INT hDoc, INT hNode, STRING sName[, STRING sNamespace = "" ])

hDoc

Handle of the XML document the parent node belongs to. Returned by XMLCreate or XMLOpen.

hNode

Handle of the parent node.e.g. <shapes>, <polygons>, <polygon>. Returned by XMLGetRoot, XMLGetChild, XMLGetParent or XMLNodeFind.

sName

The qualified name of the new element node.

sNamespace

Optional parameter. The namespace URI of the new node. For example, <shapes xmlns="http://mycompany.com/shapes/v1">.

Return Value

Handle of the newly created node, or -1 on error.

XMLClose, XMLCreate, XMLGetAttribute, XMLGetAttributeCount, XMLGetAttributeName, XMLGetAttributeValue, XMLGetChild, XMLGetChildCount, XMLGetParent, XMLGetRoot, XMLNodeFind, XMLNodeGetName, XMLNodeGetValue, XMLNodeRemove, XMLNodeSetValue, XMLOpen, XMLSave, XMLSetAttribute

Example

The example adds a new element node to the root of XML document and then adds two new element nodes to the first created node.

INT hDoc, hRoot, hNode;

hDoc = XMLCreate("shapes", "http://mycompany.com/shapes/v1");

IF hDoc <> -1 THEN

hRoot = XMLGetRoot(hDoc);

IF hRoot <> -1 THEN

hNode = XMLNodeAddChild(hDoc, hRoot, "polygons");

IF hNode <> -1 THEN

XMLNodeAddChild(hDoc, hNode, "polygon");

XMLNodeAddChild(hDoc, hNode, "polygon");

END

END

END

The xml document created by the code above:

<?xml version="1.0" encoding="utf-8" ?>

<shapes xmlns="http://mycompany.com/shapes/v1">

<polygons>

<polygon/>

<polygon/>

</polygons>

</shapes>

See Also

XML Functions

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in