UnionSelected (XmlNodelist function): Difference between revisions
m (→Examples) |
m (xpath expression) |
||
Line 13: | Line 13: | ||
<td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression.</td></tr> | <td>An <var>XmlDoc</var> or <var>XmlNode</var>, used as the context node for the <var class="term">xpath</var> expression.</td></tr> | ||
<tr><th>xpath</th> | <tr><th>xpath</th> | ||
<td>A <var>Unicode</var> string that is an <var>[[XPath]]</var> | <td>A <var>Unicode</var> string that is an <var>[[XPath#XPath_syntax|Xpath expression]]</var> which results in a nodelist. This is an optional argument whose default is a period (<code>.</code>), that is, the node referenced by the method object (<var class="term">nr</var>). Prior to <var class="product">[[Sirius Mods|"Sirius Mods"]]</var> Version 7.6, this argument is an EBCDIC string.</td></tr> | ||
</table> | </table> | ||
Revision as of 09:25, 22 May 2011
Union of XmlNodelist and selected nodes (XmlNodelist class)
UnionSelected creates an XmlNodelist that is the union of (that is, it merges) an XmlNodelist and the nodelist result of an XPath expression.
Syntax
%unionNodl = nodl:UnionSelected( nr, [xpath]) Throws XPathError
Syntax terms
%unionNodl | An XmlNodelist pointing to the nodelist that is created. |
---|---|
nodl | An XmlNodelist whose nodes are merged with the xpath result nodelist. |
nr | An XmlDoc or XmlNode, used as the context node for the xpath expression. |
xpath | A Unicode string that is an Xpath expression which results in a nodelist. This is an optional argument whose default is a period (. ), that is, the node referenced by the method object (nr). Prior to "Sirius Mods" Version 7.6, this argument is an EBCDIC string. |
Usage notes
- The XmlDoc associated with nodl and nr must be the same.
- If the result of the argument XPath expression (XPath) is empty, a copy of nodl is returned.
Examples
-
In the following example,
the UnionSelected method adds a "b" node to a nodelist of two "a" nodes:
begin %doc is object xmlDoc %doc = new %doc:loadXml('<top><a><b>05</b><b></b></a><a>55</a></top>') call %doc:print %nl1 is object xmlNodelist %nl2 is object xmlNodelist %n is object xmlNode %i is float %nl1 = %doc:selectNodes('/top/a') %nl2 = %nl1:unionSelected(%doc, '/top/a/b[1]') print 'The nodes in the merged nodelist, in document order: ' for %i from 1 to %nl2:count %n = %nl2:item(%i) print %n:serial('.', 'EBCDIC') end for end
The example results follow:
<top> <a> <b>05</b> <b/> </a> <a>55</a> </top> The nodes in the merged nodelist, in document order: <a><b>05</b><b/></a> <b>05</b> <a>55</a>
Request-Cancellation Errors
- The XmlDocs associated with nodl and nr are not the same.
- XPath is invalid.
- Insufficient free space exists in CCATEMP.
See also
- For more information about using XPath expressions, see XPath.