UnionSelected (XmlNodelist function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
m (1 revision)
(No difference)

Revision as of 17:09, 25 January 2011

Union of XmlNodelist and selected nodes (XmlNodelist class)


This function 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

%nlis An XmlNodelist pointing to the nodelist that is created.
inNlis 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 inNlis and nr must be the same.
  • If the result of the argument XPath expression (XPath) is empty, a copy of inNlis is returned.

Example

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>05</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

The example results follow:

<top> <a> 05 </a> <a>55</a> </top> The nodes in the merged nodelist, in document order: <a>05</a> 05 <a>55</a>

Request-Cancellation Errors

  • The XmlDocs associated with inNlis 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.

.if 1 = 0 .do

If you want to merge an entire nodelist onto another one, see ?? refid=$xmplcl.. .do end