Description
Inserts a new PBDOM_OBJECT into a PBDOM_ELEMENT object.
Syntax
pbdom_element_name.InsertContent(pbdom_object pbdom_object_new, pbdom_object pbdom_object_ref)
Argument |
Description |
---|---|
pbdom_element_name |
The name of a PBDOM_ELEMENT object |
pbdom_object_new |
The PBDOM_OBJECT to insert |
pbdom_object_ref |
A positional reference PBDOM_OBJECT in front of which the new PBDOM_OBJECT is to be inserted |
Return value
PBDOM_OBJECT. The PBDOM_ELEMENT object modified and returned as a PBDOM_OBJECT.
Throws
EXCEPTION_INAPPROPRIATE_USE_OF_PBDOM_OBJECT -- If an invalid PBDOM_OBJECT is added. See AddContent for the valid PBDOM_OBJECT objects that can be added to a PBDOM_ELEMENT object. This exception is also thrown if the input PBDOM_OBJECT or the reference PBDOM_OBJECT is this PBDOM_ELEMENT object itself.
EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT -- If the input PBDOM_OBJECT to insert has not been given a user-defined name. The same exception is also thrown if the reference PBDOM_OBJECT is also not given a user-defined name, unless the reference PBDOM_OBJECT is specifically set to null.
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE -- If the input PBDOM_OBJECT to insert is not associated with a derived PBDOM_OBJECT. The same exception is also thrown if the reference PBDOM_OBJECT is also not associated with a derived PBDOM_OBJECT unless the reference PBDOM_OBJECT is specifically set to null.
EXCEPTION_INVALID_ARGUMENT -- If the reference PBDOM_OBJECT (second parameter) is intended to be null but is not specifically set to null using the SetNull method.
EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT -- If the input PBDOM_OBJECT to insert already has a parent.
EXCEPTION_WRONG_PARENT_ERROR -- If the reference PBDOM_OBJECT is not a child of this PBDOM_ELEMENT object.
EXCEPTION_HIERARCHY_ERROR -- If inserting the input PBDOM_OBJECT will cause the current PBDOM_ELEMENT object to be no longer well formed.
Examples
The following PowerScript code is used to create an XML document:
pbdom_doc1 = Create PBDOM_DOCUMENT pbdom_elem_1 = Create PBDOM_ELEMENT pbdom_elem_2 = Create PBDOM_ELEMENT pbdom_elem_3 = Create PBDOM_ELEMENT pbdom_elem_1.SetName ("pbdom_elem_1") pbdom_elem_2.SetName ("pbdom_elem_2") pbdom_elem_3.SetName ("pbdom_elem_3") pbdom_doc1.NewDocument ("", "", "Root_Element", "", "") pbdom_elem_root = pbdom_doc1.GetRootElement() pbdom_elem_root.AddContent (pbdom_elem_1) pbdom_elem_root.AddContent (pbdom_elem_3)
The following XML results:
!DOCTYPE Root_Element> <Root_Element> <pbdom_elem_1 /> <pbdom_elem_3 /> </Root_Element>
The InsertContent method is used to add an element between pbdom_elem_1 and pbdom_elem_3:
pbdom_elem_root.InsertContent(pbdom_elem_2, & pbdom_elem_3)
The following XML results:
<!DOCTYPE Root_Element> <Root_Element> <pbdom_elem_1 /> <pbdom_elem_2 /> <pbdom_elem_3 /> </Root_Element>
Usage
The inserted object becomes a child of the PBDOM_ELEMENT object. The new PBDOM_OBJECT is positioned before another PBDOM_OBJECT, which is specified in the second of two parameters.
See also