Description
Creates a clone of a PBDOM_ELEMENT object.
Syntax
pbdom_element_name.Clone(boolean bDeep)
Argument |
Description |
---|---|
pbdom_element_name |
The name of a PBDOM_ELEMENT object. |
bDeep |
A boolean specifying whether a deep or shallow clone is returned. Values are true for a deep clone and false for a shallow clone. |
Return value
PBDOM_OBJECT. A clone of this PBDOM_ELEMENT object returned as a PBDOM_OBJECT.
Examples
The Clone method is used to alter the following XML:
<Telephone_Book> <Entry> <Particulars> <Name>John Doe</Name> <Age>21</Age> <Phone_Number>1234567</Phone_Number> </Particulars> </Entry> </Telephone_Book>
The Clone method is invoked from the following PowerScript code, where entry represents the Entry> element in the preceding XML:
PBDOM_ELEMENT elem_clone elem_clone = entry.Clone(true) pbdom_doc.AddContent(elem_clone)
The resulting XML contains two identical Entry> elements:
<Telephone_Book> <Entry> <Particulars> <Name>John Doe</Name> <Age>21</Age> <Phone_Number>1234567</Phone_Number> </Particulars> </Entry> <Entry> <Particulars> <Name>John Doe</Name> <Age>21</Age> <Phone_Number>1234567</Phone_Number> </Particulars> </Entry> </Telephone_Book>
Usage
This method creates and returns a duplicate of the current PBDOM_ELEMENT object. If a shallow clone is requested, this method clones the PBDOM_ELEMENT object together with its namespace information values and its PBDOM_ATTRIBUTEs and their subtrees. If a deep clone is requested, this method additionally recursively clones the subtree under the PBDOM_ELEMENT object.
A PBDOM_ELEMENT clone has no parent. However, the clone resides in the same PBDOM_DOCUMENT as its original, and if the original PBDOM_ELEMENT object is standalone, the clone is standalone.