UnionSelected (XmlNodelist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (move footer template to actual end (otherwise subsequent intervening text gets omitted); edits, tags and links)
(No difference)

Revision as of 11:25, 10 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

  1. 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.