UnionSelected (XmlNodelist function): Difference between revisions
Jump to navigation
Jump to search
m (1 revision) |
m (1 revision) |
||
Line 14: | Line 14: | ||
{{Template:XmlNodelist:UnionSelected syntax}} | {{Template:XmlNodelist:UnionSelected syntax}} | ||
===Syntax terms=== | ===Syntax terms=== | ||
< | <table class="syntaxTable"> | ||
< | <tr><th>%nlis</th> | ||
< | <td>An XmlNodelist pointing to the nodelist that is created. </td></tr> | ||
< | <tr><th>inNlis</th> | ||
< | <td>An XmlNodelist whose nodes are merged with the <i>XPath</i> result nodelist. </td></tr> | ||
< | <tr><th>nr</th> | ||
< | <td>An XmlDoc or XmlNode, used as the context node for the <i>XPath</i> expression. </td></tr> | ||
< | <tr><th>XPath</th> | ||
< | <td>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 (<i>nr</i>). Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string.</td></tr> | ||
This is an optional argument whose default is a period (.), that is, | </table> | ||
the node referenced by the method object (<i>nr</i>). | |||
Prior to ''Sirius Mods'' version 7.6, this argument is an EBCDIC string. | |||
</ | |||
==Usage notes== | ==Usage notes== |
Revision as of 17:53, 22 January 2011
Union of XmlNodelist and selected nodes (XmlNodelist class)
UnionSelected is a member of the 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><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
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 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