Count (XmlNodelist function)

From m204wiki
Revision as of 11:51, 27 April 2011 by Goff (talk | contribs) (move footer template to actual end (otherwise subsequent intervening text gets omitted); edits, tags and links)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Number of nodes in this nodelist (XmlNodelist class)

Count returns the number of nodes in an XmlNodelist.

Syntax

%number = nodl:Count

Syntax terms

%number A numeric variable for the number of nodes on XmlNodelist nodl.
nodl An XmlNodelist expression, specifying the nodelist to count.

Example

  1. In the following example, the Count method is used to limit a For loop which selectively adds nodes to the document:

    begin %doc is object xmlDoc %doc = new %doc:loadXml('<top> <a>a1</a> <a>a2</a> <a>a3</a> </top>') %nl1 is object xmlNodelist %n1 is object xmlNode %n2 is object xmlNode %j is float %nl1 = %doc:selectNodes('/top/a') for %j from 1 to %nl1:count %n1 = %nl1:item(%j) %n2 = %n1:addElement('b', 'b' With %j) end for call %d1:print end

    The example results follow:

    <top> <a> a1 <b>b1</b> </a> <a> a2 <<b>b2</b> </a> <a> a3 <b>b3</b> </a> </top>

Request-Cancellation Errors

  • Count has no request cancellation errors.

See also

  • SelectCount counts the number of nodes in an XPath expression result.