Reference Guide > X–Z Routines > XmlAddNode Function
  

XmlAddNode Function
Adds a node created with XmlNewNode to a node tree.
Usage
node_id = XmlAddNode(parent_node, new_node)
Input Parameters
parent_node—The parent node ID to attach the new node to.
new_node—The node ID of the new node to attach (returned by XmlNewNode).
Returned Value
node_id—A new XML node handle.
Keywords
Doc_id—If present, the first argument is a document ID (called the root element) as is returned by XmlNewDoc. You can only attach a single node to this top level document ID.
Discussion
This routine is used in conjunction with XmlNewNode to create and add nodes either to an existing XML document (parsed with XmlParse) or a new XML document (created with XmlNewDoc).
Example 1
This example creates two separate nodes and adds one to the other.
; Create a new node.
parent_node = XmlNewNode('ChartTitle')
; Create a second node.
child_node = XmlNewNode('Attribute', Content='Line Chart')
; Add two nodes.
new_node = XmlAddNode(parent_node, child_node)
Example 2
This example creates the same node in Example 1 but adds the newly created node to a new XML document.
; Create a new document
new_doc = XmlNewDoc('Chart')
; Create a new node.
parent_node = XmlNewNode('ChartTitle')
; Create a second node.
child_node = XmlNewNode('Attribute', Content='Line Chart')
; Add the two nodes to form a sub tree.
sub_node = XmlAddNode(parent_node, child_node)
; When adding a node to document, the doc_id keyword is required.
new_node = XmlAddNode(new_doc, sub_node, /Doc_id)

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.