Count (XmlNodelist function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 5: | Line 5: | ||
<table class="syntaxTable"> | <table class="syntaxTable"> | ||
<tr><th>%count</th> | <tr><th>%count</th> | ||
<td>A numeric variable for the number of nodes on XmlNodelist <i>nlis</i>. </td></tr> | <td>A numeric variable for the number of nodes on <var>XmlNodelist</var> <i>nlis</i>. </td></tr> | ||
<tr><th>nlis</th> | <tr><th>nlis</th> | ||
<td>An XmlNodelist expression, specifying the nodelist to count.</td></tr> | <td>An <var>XmlNodelist</var> expression, specifying the nodelist to count.</td></tr> | ||
</table> | </table> | ||
===Example=== | ===Example=== | ||
In the following example, the Count method is used to limit a For loop | In the following example, the <var>Count</var> method is used to limit a For loop | ||
which selectively adds nodes to the document: | which selectively adds nodes to the document: | ||
<p class="code">Begin | <p class="code">Begin | ||
%doc is Object XmlDoc | %doc is <var>Object</var> <var>XmlDoc</var> | ||
%doc = New | %doc = New | ||
%doc:LoadXml('<top> <a>a1</a> <a>a2</a> <a>a3</a> </top>') | %doc:LoadXml('<top> <a>a1</a> <a>a2</a> <a>a3</a> </top>') | ||
%nl1 is Object XmlNodelist | %nl1 is <var>Object</var> <var>XmlNodelist</var> | ||
%n1 is Object XmlNode | %n1 is <var>Object</var> <var>XmlNode</var> | ||
%n2 is Object XmlNode | %n2 is <var>Object</var> <var>XmlNode</var> | ||
%j is Float | %j is <var>Float</var> | ||
%nl1 = %doc:SelectNodes('/top/a') | %nl1 = %doc:SelectNodes('/top/a') | ||
For %j from 1 to %nl1:Count | For %j from 1 to %nl1:<var>Count</var> | ||
%n1 = %nl1:Item(%j) | %n1 = %nl1:Item(%j) | ||
%n2 = %n1:AddElement('b', 'b' With %j) | %n2 = %n1:AddElement('b', 'b' With %j) | ||
Line 49: | Line 49: | ||
===Request-Cancellation Errors=== | ===Request-Cancellation Errors=== | ||
<ul> | <ul> | ||
<li>Count has no request cancellation errors. | <li><var>Count</var> has no request cancellation errors. | ||
</ul> | </ul> | ||
Revision as of 17:45, 25 January 2011
Number of nodes in this nodelist (XmlNodelist class)
Syntax
%number = nodl:Count
Syntax terms
%count | A numeric variable for the number of nodes on XmlNodelist nlis. |
---|---|
nlis | An XmlNodelist expression, specifying the nodelist to count. |
Example
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 b1 </a> <a> a2 b2 </a> <a> a3 b3 </a> </top>
Request-Cancellation Errors
- Count has no request cancellation errors.
See also
- SelectCount counts the number of nodes in an XPath expression result.