Description
Detaches a PBDOM_CHARACTERDATA object from its parent.
Syntax
pbdom_chardata_name.Detach()
Return value
PBDOM_OBJECT.
Throws
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE -- If this PBDOM_CHARACTERDATA is not a reference to an object derived from PBDOM_CHARACTERDATA.
Examples
This example creates a PBDOM_DOCUMENT based on the following DOM tree:
<abc> <data>Data</data> </abc>
The PowerScript code obtains the root element, uses it to obtain the child element, and then obtains an array of the child element's own children. This array has a single item, the PBDOM_TEXT object with the text Data. The array can be cast to a PBDOM_CHARACTERDATA object because it does not contain any objects that are not derived from PBDOM_CHARACTERDATA.
Calling Detach separates the PBDOM_TEXT object from its parent PBDOM_OBJECT, data.
PBDOM_Builder pbdombuilder_new
pbdom_document pbdom_doc
pbdom_document pbdom_owner_doc
PBDOM_CHARACTERDATA pbdom_chardata
PBDOM_OBJECT pbdom_obj_array[]
string strXML = "<abc><data>Data</data></abc>"
TRY
pbdombuilder_new = Create PBDOM_Builder
pbdom_doc = pbdombuilder_new.BuildFromString (strXML)
pbdom_doc.GetRootElement(). &
GetChildElement("data"). &
GetContent(pbdom_obj_array)
pbdom_chardata = pbdom_obj_array[1]
pbdom_chardata.Detach()
pbdom_doc.SaveDocument("c:\pbdom_doc_1.xml")
Destroy pbdombuilder_new
CATCH (PBDOM_Exception except)
MessageBox ("Exception Occurred", except.Text)
END TRYWhen the document is saved to a file, the file's contents are as follows, because the PBDOM_TEXT object was removed from data:
<abc> <data/> </abc>
Usage
Nothing occurs if the PBDOM_CHARACTERDATA object has no parent.


