Item (XmlNodelist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (edits, tags and links)
 
(2 intermediate revisions by 2 users not shown)
Line 15: Line 15:


==Usage notes==
==Usage notes==
<uL><li>Under <var class="product">[[Sirius Mods]]</var> Version 6.8 and later, the method name, <var>Item</var>, is not necessary on an <var>XmlNodelist</var> <var>Item</var> reference.  For example (showing that the <var>Item</var> method name can be left off), if <code>%nlis</code> is an <var>XmlNodelist</var> in the following code:
<uL><li>The method name, <var>Item</var>, is not necessary on an <var>XmlNodelist</var> <var>Item</var> reference.  For example (showing that the <var>Item</var> method name can be left off), if <code>%nlis</code> is an <var>XmlNodelist</var> in the following code:
<p class="code">for %i from 1 To %nlis:[[Count_(XmlNodelist_function)|count]]
<p class="code">for %i from 1 To %nlis:[[Count_(XmlNodelist_function)|count]]
   %nod = %nlis(%i)
   %nod = %nlis(%i)
Line 27: Line 27:


==Examples==
==Examples==
<ol><li>
This example prints the node type and the names and/or values of items on an <var>XmlNodelist</var>; <code>%nod = %nlis(%i)</code> implicitly uses the <var>Item</var> method:
This example prints the node type and the names and/or values of items on an <var>XmlNodelist</var>; <code>%nod = %nlis(%i)</code> implicitly uses the <var>Item</var> method:
<p class="code">begin
<p class="code">begin
Line 73: Line 72:
   </a>
   </a>
</top>
</top>
</p></ol>
</p>


==Request-Cancellation Errors==
==Request-cancellation errors==
This list is not exhaustive: it does <i>not</i> include all the errors that are request  cancelling.
<ul>
<ul>
<li>The selected item number (<var class="term">number</var>) is not in the range from 1 to the number of items on the <var class="term">nodl</var>.
<li>The selected item number (<var class="term">number</var> argument) is not in the range from 1 to the number of items on the <var class="term">nodl</var> object.
</ul>
</ul>


==See also==
==See also==
{{Template:XmlNodelist:Item footer}}
{{Template:XmlNodelist:Item footer}}

Latest revision as of 20:40, 3 March 2014

Retrieve an item from this nodelist (XmlNodelist class)

Item creates an XmlNode from one of the items on an XmlNodelist.

Syntax

%nod = nodl:Item( number)

Syntax terms

%nod An XmlNode that points to the selected node.
nodl The XmlNodelist from which the item is taken.
number A positive integer that identifies which item to select.

Usage notes

  • The method name, Item, is not necessary on an XmlNodelist Item reference. For example (showing that the Item method name can be left off), if %nlis is an XmlNodelist in the following code:

    for %i from 1 To %nlis:count %nod = %nlis(%i) ...

    The preceding example is the same as this one, with the Item method name coded:

    for %i from 1 To %nlis:count %nod = %nlis:item(%i) ...

Examples

This example prints the node type and the names and/or values of items on an XmlNodelist; %nod = %nlis(%i) implicitly uses the Item method:

begin %i is float %doc is object xmlDoc %nod is object xmlNode %nlis is object xmlnodelist %t enumeration xmlNodeType %doc = new %doc:loadXml('<top><a b="b1"><a1/></a> - <a><a2 b="b2"></a2></a></top>') %nlis = %doc:selectNodes('//.') for %i from 1 To %nlis:count %nod = %nlis(%i) %t = %nod:type if %t eq root then print 'Item ' %i ': Root' elseIf %t eq element then print 'Item ' %i ': Element' and %nod:qName elseIf %t eq attribute then print 'Item ' %i ': Attribute' and %nod:qName - with '="' with %nod:value with '"' else print 'Item ' %i ':' and %t:ToString - and '=' and %nod:value end if end for %doc:print end

The example result follows:

Item 1: Root Item 2: Element top Item 3: Element a Item 4: Element a1 Item 5: Element a Item 6: Element a2 <top> <a b="b1"> <a1/> </a> <a> <a2 b="b2"/> </a> </top>

Request-cancellation errors

This list is not exhaustive: it does not include all the errors that are request cancelling.

  • The selected item number (number argument) is not in the range from 1 to the number of items on the nodl object.

See also