Traversing the Document Object Model

To manipulate the content of a node in the DOM, you must locate the node.

The top-level nodes that represent the sections of a document can be accessed directly by using the Sections collection. The shapes within a dashboard are accessible through its Shapes collection. However, there is no collection for the children of a node.

Methods are provided to access the children of a node:

To iterate over all subnodes of a given node, use getChildren() to retrieve a list that contains them. Use getChildrenOfType() to limit this to the children of a particular type. For example, the Root.MyDocument node contains a Rpt.DocComp node for each section in the document, which can be located using this line:

var sections = root.getChildrenOfType(“Rpt.DocComp”);

A node is added as a child of another by using addChild(). Use this to copy a node from one part of the DOM (or the DOM of another document) to another location.

To remove a child node, use removeChild().

Note:

The list of children returned by getChildren() and getChildrenOfType() is read-only. If you update the list by assigning a new value to an entry, this does not affect the node. However, the current list of nodes can be replaced using setChildren().

The content of a sub-tree of the document can be written to the log using dump(). By default, this dumps the tree to standard output, but by supplying parameters, it can be written to any print stream.