SelectCount (XmlDoc/XmlNode function): Difference between revisions
Jump to navigation
Jump to search
(Created page with "<span style="font-size:120%; color:black"><b>Count of selected nodes</b></span> SelectCount function SelectCount function...") |
m (1 revision) |
(No difference)
|
Revision as of 00:33, 7 December 2010
Count of selected nodes
SelectCount is a member of the XmlDoc and XmlNode classes.
This method counts the number of nodes selected by an XPath expression.
Syntax
%count = nr:SelectCount(XPath)
Syntax Terms
- %count
- A numeric variable for the number of nodes on XmlNodelist nlis.
- nr
- An XmlDoc or XmlNode, used as the context node for the XPath expression. If an XmlDoc, the Root node is the context node.
- XPath
- A Unicode string that is an XPath expression that results in a nodelist. The count of nodes in this nodelist is returned. Prior to Sirius Mods version 7.6, this is an EBCDIC string.
Usage Notes
- If the result of the argument XPath expression (XPath) is empty, zero is returned.
Examples
- In the following example, SelectCount counts the “a” node
children of node “top,” then the text node children of
those “a” nodes:
Begin %doc is Object XmlDoc %j is Float %k is Float %doc = New %doc:LoadXml('<top> <a>a1</a> <a>a2</a> <a>a3</a> </top>') Call %doc:Print('/') %j = %doc:SelectCount('/top/a') %k = %doc:SelectCount('/top/a/text()') Print %j ' and ' %k End
The example results follow:
<top> <a>a1</a> <a>a2</a> <a>a3</a> </top> 3 and 3
- The following
statements count all the nodes in the document
and all the attributes in the document, respectively.
Print 'Count of non-attribute nodes:' And %doc:CountSelected('//node()') Print 'Count of attribute nodes:' And %doc:CountSelected('//@*')
Request-Cancellation Errors
- XPath is invalid.
- Insufficient free space exists in CCATEMP.