SetContent

Description

Sets the entire content of the PBDOM_DOCUMENT object, removing pre-existing children first.

Syntax

pbdom_document_name.SetContent(pbdom_object pbdom_object_array)

Argument

Description

pbdom_document_name

The name of a PBDOM_DOCUMENT object

pbdom_object_array

An array of PBDOM_OBJECTs set as the contents of the PBDOM_DOCUMENT object


pbdom_object_array must contain only PBDOM_OBJECT objects that can legally be set as the contents of a PBDOM_DOCUMENT object. The SetContent method restricts the array to one PBDOM_ELEMENT object to set as the root element of the PBDOM_DOCUMENT object from which the method is invoked. The SetContent method also restricts the array to one PBDOM_DOCTYPE object to set as the DOCTYPE of the PBDOM_DOCUMENT object.

Return value

PBDOM_OBJECT. The modified PBDOM_DOCUMENT object returned as a PBDOM_OBJECT.

Throws

EXCEPTION_ILLEGAL_PBOBJECT -- An array item is not a valid PBDOM object. This can happen if the array item has not been initialized properly or is a null object reference.

EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT -- An array item is nameable and has not been given a user-defined name.

EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE -- An array item is not associated with a derived PBDOM_OBJECT.

EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT -- An array item already has a parent PBDOM_OBJECT.

EXCEPTION_MULTIPLE_ROOT_ELEMENT -- The array contains more than one PBDOM_ELEMENT. The array must contain at most one PBDOM_ELEMENT that is set as the root element of this document.

EXCEPTION_MULTIPLE_DOCTYPE -- The array contains more than one PBDOM_DOCTYPE. The array must contain at most one PBDOM_DOCTYPE that is set as the DOCTYPE of this document.

EXCEPTION_MULTIPLE_XMLDECL -- The array contains more than one PBDOM_PROCESSINGINSTRUCTION that has been constructed into an XML Declaration.

EXCEPTION_INAPPROPRIATE_USE_OF_PBDOM_OBJECT -- An array item is not allowed to be set as a document-level content.

Usage

The supplied array contains PBDOM_OBJECTs that can legally be set as the content of a PBDOM_DOCUMENT object.

For example, a PBDOM_DOCUMENT object accepts only an array that contains PBDOM_ELEMENT, PBDOM_COMMENT, PBDOM_DOCTYPE, or PBDOM_PROCESSINGINSTRUCTION objects. In addition, the array can contain at most one PBDOM_ELEMENT object that it sets as its root element, at most one PBDOM_DOCTYPE object that it sets as its DOCTYPE, and at most one XML declaration .PBDOM_PROCESSINGINSTRUCTION.

In the event of an exception, the original contents of this PBDOM_DOCUMENT object are unchanged, and the PBDOM_OBJECTs contained in the supplied array are unaltered.

See also

AddContent

GetContent

InsertContent

RemoveContent