InsertCommentBefore (XmlNode function): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%; color:black"><b>Insert Comment before XmlNode</b></span>
{{Template:XmlNode:InsertCommentBefore subtitle}}
[[Category:XmlNode methods|InsertCommentBefore function]]
[[Category:XmlNode methods|InsertCommentBefore function]]
[[Category:XmlDoc API methods]]
[[Category:XmlDoc API methods]]
Line 11: Line 11:
This callable function inserts a Comment node as the immediate
This callable function inserts a Comment node as the immediate
sibling preceding the method XmlNode.
sibling preceding the method XmlNode.
===Syntax===
==Syntax==
  [%nod =] nod:InsertCommentBefore(value)
{{Template:XmlNode:InsertCommentBefore syntax}}
 
===Syntax terms===
====Syntax Terms====
<dl>
<dl>
<dt><i>%nod</i>
<dt><i>%nod</i>
Line 29: Line 28:
</dl>
</dl>


===Usage Notes===
==Usage notes==
<ul>
<ul>
<li>Since the return value of InsertCommentBefore is frequently not needed,
<li>Since the return value of InsertCommentBefore is frequently not needed,
Line 39: Line 38:
For more information about the effects of this version 7.6
For more information about the effects of this version 7.6
change, see [[Strings and Unicode]].
change, see [[Strings and Unicode]].
<li>There is a very small &ldquo;one-time&rdquo; processing cost
<li>There is a very small "one-time" processing cost
if certain XPath operations are performed after using this method, because
if certain XPath operations are performed after using this method, because
Insert-Before methods are guaranteed to add a node out of document order.
Insert-Before methods are guaranteed to add a node out of document order.
Line 51: Line 50:


In the following example,
In the following example,
a Comment node is inserted before node &ldquo;a&rdquo;:
a Comment node is inserted before node "a":
<pre>
<pre>
     Begin
     Begin
Line 92: Line 91:
method object.
method object.
<li>For hints about inserting a node ''after'' a sibling node, see
<li>For hints about inserting a node ''after'' a sibling node, see
the &ldquo;Example&rdquo; section in [[InsertElementBefore (XmlNode function)|InsertElementBefore]].
the "Example" section in [[InsertElementBefore (XmlNode function)|InsertElementBefore]].
</ul>
</ul>

Revision as of 16:58, 22 January 2011

Insert a Comment before this node (XmlNode class)

[Requires Janus SOAP]

InsertCommentBefore is a member of the XmlNode class.

This callable function inserts a Comment node as the immediate sibling preceding the method XmlNode.

Syntax

[%outNod =] nod:InsertCommentBefore( value)

Syntax terms

%nod
If specified, an XmlNode that is set to point to the Comment node that is added.
nod
XmlNode pointing to the (non-Root) node before which the Comment node is inserted.
value
A Unicode string that is the value of the added Comment node; stored exactly as is, that is, without whitespace normalization.

Usage notes

  • Since the return value of InsertCommentBefore is frequently not needed, you may want to Call it instead of saving its return value.
  • As of Sirius Mods version 7.3, value may include only non-null EBCDIC characters that translate to Unicode. As of Sirius Mods version 7.6, all Janus SOAP string arguments and results are Unicode or are converted to Unicode. For more information about the effects of this version 7.6 change, see Strings and Unicode.
  • There is a very small "one-time" processing cost if certain XPath operations are performed after using this method, because Insert-Before methods are guaranteed to add a node out of document order. In general, processing an XmlDoc is likely to be more efficient if you add nodes in document order (that is, top-to-bottom, left-to-right).
  • To modify the value stored in a Comment node, change the Value property of an XmlNode that points to the Comment node.

Example

In the following example, a Comment node is inserted before node "a":

    Begin
    %doc is Object XmlDoc
    %doc = New
    Call %doc:LoadXml('<top><a><b>05</b></a></top>')
    %n1 is Object XmlNode
    %n1 = %doc:SelectSingleNode('top/a')
    Call %n1:InsertCommentBefore('legacy code follows')
    Call %doc:Print
    End

The example results follow:

    <top>
       <!--legacy code follows-->
       <a>
          <b>05</b>
       </a>
    </top>

Request-Cancellation Errors

  • Nod is the Root node.
  • Argument value violates the rules for an XML comment.


See Also

  • AddComment (?? reftxt=AddComment refid=addcom.) also adds a Comment node. InsertCommentBefore adds a Comment as the immediately preceding sibling of the node pointed to by the method object; AddComment adds a Comment as the last child of the node pointed to by the method object.
  • For hints about inserting a node after a sibling node, see the "Example" section in InsertElementBefore.