Back to Contents


The NodeList class

Summary:

See also: Built-in Classes, XML Utils


Basics

Purpose:

The NodeList class holds a list of DomNode objects created from a selection method.

Syntax:

om.NodeList

Notes:

  1. A NodeList object is created from a DomNode.selectByTagName() or DomNode.selectByPath() method.

Methods:

Object Methods
Name Description
item( index INTEGER )
 
RETURNING om.DomNode
Returns the DomNode object at the given position (first is 1). Returns NULL if the item does not exist.
getLength( )
 
RETURNING INTEGER
Returns the number of items in the list.

Examples

Example 1:

Search for child nodes by tag name:

01 MAIN
02   DEFINE nl om.NodeList
03   DEFINE r, n om.DomNode
04   DEFINE i INTEGER
05
06   LET r = ui.Interface.getRootNode()
07   LET nl = r.selectByTagName("Form")
08
09   FOR i=1 to nl.getLength()
10     LET n = nl.item(i)
11     DISPLAY n.getAttribute("name")
12   END FOR
13
14 END MAIN

Example 2:

Search for child nodes by XPath:

01 MAIN
02   DEFINE nl om.NodeList
03   DEFINE r, n om.DomNode
04   DEFINE i INTEGER
05
06   LET r = ui.Interface.getRootNode()
07   LET nl = r.selectByPath("//Window[@name=\"screen\"]")
08
09   FOR i=1 to nl.getLength()
10     LET n = nl.item(i)
11     DISPLAY n.getAttribute("name")
12   END FOR
13
14 END MAIN