AddContent – PB Docs 2021

AddContent

Description

Allows you to add a new PBDOM_OBJECT into the current
PBDOM_DOCUMENT object.

Syntax

Argument

Description

pbdom_document_name

The name of a PBDOM_DOCUMENT object

pbdom_object_ref

The PBDOM_OBJECT to add

Return value

PBDOM_OBJECT. The return value is the newly modified
PBDOM_DOCUMENT object returned as a PBDOM_OBJECT.

Throws

EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT — The input PBDOM_OBJECT
is nameable, but it currently has no name.

EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE — The input PBDOM_OBJECT
object is not associated with a derived PBDOM_OBJECT class
object.

EXCEPTION_INAPPROPRIATE_USE_OF_PBDOM_OBJECT — Adding the input
PBDOM_OBJECT is inappropriate. See description section below on the
valid PBDOM_OBJECTs that can be added to a PBDOM_DOCUMENT object.

EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT — If the PBDOM_OBJECT
to be added already has a parent PBDOM_OBJECT.

EXCEPTION_MULTIPLE_ROOT_ELEMENT — If a PBDOM_ELEMENT is to be
added and this document already has a root element.

EXCEPTION_MULTIPLE_DOCTYPE — If a PBDOM_DOCTYPE is to be added
and this document already has a DOCTYPE.

Examples

The document pbdom_doc1 is created with three elements:
pbdom_elem_1, pbdom_elem_2, and pbdom_elem_3. pbdom_elem_2 and
pbdom_elem_3 are set as children of pbdom_element_1.
pbdom_doc1.GetRootElement().Detach()detaches the root element from
pbdom_doc1. pbdom_elem_1 is added as a child of pbdom_doc1 with
pbdom_doc1.AddContent(pbdom_elem_1).

The original root element <Root_Element> has been detached
and replaced by <pbdom_elem_1>. The document is transformed
to:

If the following root element detachment statement is omitted, an
exception is thrown:

pbdom_doc1.GetRootElement().Detach()

Usage

The new PBDOM_OBJECT becomes a child PBDOM_OBJECT of the current
PBCOM_DOCUMENT. The following table lists the PBDOM_OBJECTs that can be
added to a PBDOM_DOCUMENT object and the restrictions for their
addition.

PBDOM_OBJECT

Restrictions

PBDOM_ELEMENT

Allowed to be added only if this document currently
does not contain any root element. Otherwise the exception
EXCEPTION_MULTIPLE_ROOT_ELEMENT is thrown.

The
PBDOM_ELEMENT to be added must not already have a parent
PBDOM_OBJECT. If it does, the exception
EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT is
thrown.

PBDOM_COMMENT

Any number of PBDOM_COMMENT objects can be added to
a document.

The only restriction is that the
PBDOM_COMMENT must not already have a parent. If so, the
exception EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT is
thrown.

PBDOM_PROCESSINGINSTRUCTION

Any number of PBDOM_PROCESSINGINSTRUCTION objects
can be added to a document.

The only restriction is
that the PBDOM_PROCESSINGINSTRUCTION must not already have a
parent. If so, the exception
EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT is
thrown.

PBDOM_DOCTYPE

Allowed to be added only if this document currently
does not contain any DOCTYPE node. Otherwise the exception
EXCEPTION_MULTIPLE_DOCTYPE is thrown.

The
PBDOM_DOCTYPE to be added must not already have a parent
PBDOM_OBJECT. If it does, the exception
EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT is
thrown.

See also

GetContent

InsertContent

RemoveContent

SetContent


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x