AddPI (XmlDoc/XmlNode function): Difference between revisions
Jump to navigation
Jump to search
m (→Syntax terms) |
m (1 revision) |
(No difference)
|
Revision as of 21:09, 24 May 2011
Add Processing Instruction to XmlDoc Root or to Element XmlNode (XmlDoc and XmlNode classes)
[Requires Janus SOAP]
The AddPI callable function adds a PI (Processing Instruction) node as the last child of the Root node or Element node referenced by the method object.
Syntax
[%nod =] nr:AddPI( name, value)
Syntax terms
%nod | If specified, an XmlNode that is set to point to the PI node that is added. |
---|---|
nr | An XmlDoc or XmlNode that refers to the Root or Element node that is the parent of the added PI node. |
name | A Unicode string that is the target of the added PI node; this can be thought of as the "name" of the PI. It must conform to the XML syntax rules for a PI target; the maximum length of the name is 300 characters (127 characters prior to version 7.9, and 100 characters prior to version 7.7). |
value | A Unicode string that is the value of the added PI node; stored exactly as is, that is, without whitespace normalization. |
Usage notes
- Since the return value of AddPI is frequently not needed, you may want to Call it instead of saving its return value.
- Processing of 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 an PI node, change the Value property of an XmlNode that points to the PI node.
- As of Sirius Mods Version 7.3, the method arguments may include only non-null EBCDIC characters that translate to Unicode. As of Sirius Mods Version 7.6, these argument strings are Unicode or are converted to Unicode. For more information about the effects of this Version 7.6 change, see "Strings and Unicode".
Examples
-
In the following example, one PI node is added as the last child of element "b":
begin %doc is object xmlDoc %doc = new %doc:loadXml('<top><a><b>05</b></a></top>') %n1 is object xmlNode %n1 = %doc:selectSingleNode('top/a/b') Call %n1:addPI('processing_app', 'ignore pre-2004') call %doc:print end
The example result, showing the serialized format of the processing instruction, follows:
<top> <a> <b> 05 <?processing_app ignore pre-2004?> </b> </a> </top>
Request-Cancellation Errors
- Nr is neither the Root nor an Element node.
- Argument name violates the rules for an XML processing instruction target.
- Argument value violates the rules for an XML processing instruction value.
See also
- InsertPIBefore also adds a PI node. AddPI adds a PI as the last child of the node pointed to by the method object; InsertPIBefore adds a PI as the immediately preceding sibling of the node pointed to by the method object.