PBDOM_ELEMENT:
SetContent method
Description
Sets
the content of the PBDOM_ELEMENT object using an array
containing PBDOM_OBJECT objects legal for a PBDOM_ELEMENT
object. Any existing children of the PBDOM_ELEMENT object
are removed when the SetContent method is invoked.
If the input array reference is null, all
contents of the PBDOM_ELEMENT object are removed. If the
array contains illegal objects, an exception is thrown, and nothing
is altered.
Syntax
1 |
<span>pbdom_element_name.</span>SetContent(pbdom_object <span>pbdom_object_array</span>[]) |
Argument |
Description |
---|---|
pbdom_element_name |
The name of a PBDOM_ELEMENT |
pbdom_object_array |
An array of PBDOM_OBJECTS to |
Return Values
PBDOM_OBJECT. The PBDOM_ELEMENT object modified
and returned as a PBDOM_OBJECT.
Throws
EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT – If
an input PBDOM_OBJECT array item has not been given a user-defined
name.
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE – If
an input PBDOM_OBJECT array item is not associated with
a derived PBDOM_OBJECT.
EXCEPTION_PBDOM_OBJECT_ALREADY_HAS_PARENT – If
an input PBDOM_OBJECT array item already has a parent PBDOM_OBJECT.
EXCEPTION_INAPPROPRIATE_USE_OF_PBDOM_OBJECT – If
an inappropriate PBDOM_OBJECT array item is found. This
happens if the PBDOM_OBJECT array item is not allowed to
be added as a child of a PBDOM_ELEMENT object (for example,
a PDBOM_DOCUMENT).
EXCEPTION_HIERARCHY_ERROR – If
one of the PBDOM_OBJECT array items, if set as part of
the contents of this PBDOM_ELEMENT object, will cause the
current PBDOM_ELEMENT object to be no longer well formed.
Examples
The SetContent method is invoked
on the following XML fragment:
1 |
<Telephone_Book><br>     <Entry><br>          <Particulars><br>               <Name>John Doe</Name><br>               <Age>21</Age><br>               <Phone_Number>1234567</Phone_Number><br>          </Particulars><br>     </Entry><br></Telephone_Book> |
The SetContent method is invoked from the
following PowerScript code:
1 |
PBDOM_OBJECT pbdom_obj_array[]<br> <br>pbdom_obj_array[1] = entry_1<br>pbdom_obj_array[2] = entry_2<br> <br>pbdom_doc.GetRootElement().SetContent(pbdom_obj_array) |
The entry_1 PBDOM_ELEMENT
object contains the following:
1 |
     <Entry><br>          <Particulars><br>               <Name>James Gomez</Name><br>               <Age>25</Age><br>               <Phone_Number>1111111</Phone_Number><br>          </Particulars><br>     </Entry> |
The entry_2 PBDOM_ELEMENT
object contains the following:
1 |
     <Entry><br>          <Particulars><br>               <Name>Mary Jones</Name><br>               <Age>22</Age><br>               <Phone_Number>2222222</Phone_Number><br>          </Particulars><br>     </Entry> |
The SetContent method returns the following:
1 |
<Telephone_Book><br>     <Entry><br>          <Particulars><br>               <Name>James Gomez</Name><br>               <Age>25</Age><br>               <Phone_Number>1111111</Phone_Number><br>          </Particulars><br>     </Entry><br>     <Entry><br>          <Particulars><br>               <Name>Mary Jones</Name><br>               <Age>22</Age><br>               <Phone_Number>2222222</Phone_Number><br>          </Particulars><br>     </Entry><br></Telephone_Book> |
Usage
Only the following PBDOM_OBJECT types can be validly
added to a PBDOM_ELEMENT object:
-
PBDOM_ELEMENT
-
PBDOM_CDATA
-
PBDOM_COMMENT
-
PBDOM_ENTITYREFERENCE
-
PBDOM_PROCESSINGINSTRUCTION
-
PBDOM_TEXT