Next / Previous / Contents / TCC Help System / NM Tech homepage

8.2. Accessing the list of child elements

In many ways, an Element instance acts like a Python list, with its XML child elements acting as the members of that list.

You can use the Python len() function to determine how many children an element has. For example, if node is an Element instance with five element children, len(node) will return the value 5.

You can add, replace, or delete children of an element using regular Python list operations. For example, if an Element instance node has three child elements, node[0] is the first child, and node[2] is the third child.

In the examples that follow, assume that E is an Element instance.