Count (XmlNodelist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Template:XmlNodelist:Count subtitle}}
{{Template:XmlNodelist:Count subtitle}}
<var>Count</var> returns the number of nodes in an <var>XmlNodelist</var>.


==Syntax==
==Syntax==
Line 7: Line 6:
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th>%number</th>
<tr><th>%number</th>
<td>A numeric variable for the number of nodes on <var>XmlNodelist</var> <var class="term">nodl</var>. </td></tr>
<td>A numeric variable for the number of nodes in <var>XmlNodelist</var> <var class="term">nodl</var>. </td></tr>
<tr><th>nodl</th>
<tr><th>nodl</th>
<td>An <var>XmlNodelist</var> expression, specifying the <var>XmlNodelist</var> to count.</td></tr>
<td>An <var>XmlNodelist</var> expression, specifying the <var>XmlNodelist</var> to count.</td></tr>
Line 13: Line 12:


==Example==
==Example==
<ol><li>In the following example, the <var>Count</var> method is used to limit a For loop which selectively adds nodes to the document:
In the following example, the <var>Count</var> method is used to limit a <var>For</var> loop which selectively adds nodes to the document:
<p class="code">begin
<p class="code">begin
   %doc is object xmlDoc
   %doc is object xmlDoc
Line 46: Line 45:
   </a>
   </a>
</top></nowiki>
</top></nowiki>
</p></ol>
</p>


==Request-Cancellation Errors==
==Request-cancellation errors==
<ul>
<ul>
<li><var>Count</var> has no request cancellation errors.
<li><var>Count</var> has no request-cancellation errors.
</ul>
</ul>



Latest revision as of 21:12, 31 May 2011

Number of nodes in this nodelist (XmlNodelist class)


Syntax

%number = nodl:Count

Syntax terms

%number A numeric variable for the number of nodes in XmlNodelist nodl.
nodl An XmlNodelist expression, specifying the XmlNodelist 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 <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