PBDOM_ATTRIBUTE:
RemoveContent method
Description
Removes
the input PBDOM_OBJECT from the PBDOM_ATTRIBUTE.
Syntax
1 |
<span>pbdom_attribute_name.</span>RemoveContent(pbdom_object<span> pbdom_object_ref</span>) |
Argument |
Description |
---|---|
pbdom_attribute_name |
The name of the PBDOM_ATTRIBUTE |
pbdom_object_ref |
The PBDOM_OBJECT child to be |
Return Values
Boolean. Returns true if
the content has been successfully removed and false otherwise.
Throws
EXCEPTION_INVALID_ARGUMENT – The
input PBDOM_OBJECT is invalid. This can happen if it has
not been initialized properly or is a null object reference.
EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE – This PBDOM_ATTRIBUTE
object or the input PBDOM_OBJECT is not associated with
a derived PBDOM_OBJECT class object.
EXCEPTION_USE_OF_UNNAMED_PBDOM_OBJECT – This PBDOM_ATTRIBUTE
or the PBDOM_OBJECT to be removed is nameable and has not
been given a user-defined name.
EXCEPTION_WRONG_DOCUMENT_ERROR – The
input PBDOM_OBJECT is not contained within the same PBDOM_DOCUMENT
as this PBDOM_ATTRIBUTE.
EXCEPTION_WRONG_PARENT_ERROR – The
input PBDOM_OBJECT is not a child of the current PBDOM_ATTRIBUTE.
Examples
This example adds an attribute to the root element
with the name my_attr and text content “attribute
text”. It then creates a PBDOM_ENTITYREFERENCE object
named ent_ref and inserts it before
the attribute’s current content.
At this point, my_attr contains
two child PBDOM_OBJECTs: a PBDOM_TEXT containing “attribute
text” and a PBDOM_ENTITYREFERENCE named ent_ref.
The element looks like this when serialized:
1 |
<root my_attr="attribute text&ent_ref;"> |
A call to GetContent returns an array containing
these two PBDOM_OBJECTs. pbdom_obj_array[1] should
point to the PBDOM_TEXT. After pbdom_obj_array[1] is
removed from my_attr, the element
looks like this when serialized: <root
.
my_attr="&ent_ref;">
1 |
PBDOM_DOCUMENT     pbdom_doc<br>PBDOM_ATTRIBUTE    pbdom_attr<br>PBDOM_ENTITYREFERENCE   pbdom_entref<br>PBDOM_OBJECT            pbdom_obj_array[]<br> <br>try<br>  pbdom_doc = Create PBDOM_DOCUMENT<br>  pbdom_entref = Create PBDOM_ENTITYREFERENCE<br> <br>  // Create a new document object.<br>  pbdom_doc.NewDocument ("root")<br>  // Add an attribute "my_attr" to the root element.<br>  pbdom_doc.GetRootElement().SetAttribute("my_attr", &<br>     "attribute text")<br> <br>  // Set the name of our PBDOM_ENTITYREFERENCE.  <br>  pbdom_entref.SetName ("ent_ref")<br>  <br>  // Add the entity reference to the root <br>  // element's "my_attr" attribute.<br>  pbdom_doc.GetRootElement(). &<br>     GetAttribute("my_attr"). AddContent(pbdom_entref)<br> <br>  // Get the existing contents of "my_attr"<br>  pbdom_doc.GetRootElement().GetAttribute("my_attr").&<br>     GetContent(pbdom_obj_array)<br> <br>  // Remove PBDOM_TEXT object from "my_attr"<br>  pbdom_doc.GetRootElement().GetAttribute("my_attr").&<br>     RemoveContent(pbdom_obj_array[1])<br>  <br>// Test the text contents of "my_attr  "<br>  if pbdom_doc.GetRootElement(). &<br>     GetAttribute("my_attr").GetText() = &<br>     "&ent_ref;" then<br>    MessageBox ("Pass", &<br>      "GetText() on my_attr is correct.")<br>  else<br>    MessageBox ("Fail", <br>      "GetText() on my_attr is incorrect.")<br>  end if<br>  <br>catch (pbdom_exception pbdom_e)<br>  MessageBox ("PBDOM_EXCEPTION", pbdom_e.GetMessage())<br>end try |
Usage
The RemoveContent method removes the input
PBDOM_OBJECT from this PBDOM_ATTRIBUTE. Currently,
only a PBDOM_TEXT and a PBDOM_ENTITYREFERENCE
object can be part of the contents of a PBDOM_ATTRIBUTE.
Therefore, the input PBDOM_OBJECT must be either a PBDOM_TEXT
or a PBDOM_ENTITYREFERENCE object.